Skip to content

Commit

Permalink
Run generate.py
Browse files Browse the repository at this point in the history
  • Loading branch information
heyman committed Jan 31, 2024
1 parent a01ea92 commit 68cb99a
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 15 deletions.
10 changes: 9 additions & 1 deletion 10/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
WEBHOOK_CURL_OPTIONS = os.environ.get("WEBHOOK_CURL_OPTIONS") or ""
KEEP_BACKUP_DAYS = int(os.environ.get("KEEP_BACKUP_DAYS", 7))
FILENAME = os.environ.get("FILENAME", DB_NAME + "_%Y-%m-%d")
PG_DUMP_EXTRA_OPTIONS = os.environ.get("PG_DUMP_EXTRA_OPTIONS") or ""

file_name = dt.strftime(FILENAME)
backup_file = os.path.join(BACKUP_DIR, file_name)
Expand Down Expand Up @@ -69,7 +70,14 @@ def take_backup():
env.update({'PGPASSWORD': DB_PASS, 'PGHOST': DB_HOST, 'PGUSER': DB_USER, 'PGDATABASE': DB_NAME, 'PGPORT': DB_PORT})

# trigger postgres-backup
cmd("pg_dump -Fc > %s" % backup_file, env=env)
command = [
"pg_dump",
"-Fc",
]
if PG_DUMP_EXTRA_OPTIONS:
command.append(PG_DUMP_EXTRA_OPTIONS)
command.append("> %s" % backup_file)
cmd(" ".join(command), env=env)

def upload_backup():
opts = "--storage-class=%s %s" % (S3_STORAGE_CLASS, S3_EXTRA_OPTIONS)
Expand Down
2 changes: 1 addition & 1 deletion 10/restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def cmd(command, **kwargs):
sys.stderr.write("\n".join([
"Command execution failed. Output:",
"-"*80,
e.output,
e.output.decode(),
"-"*80,
""
]))
Expand Down
10 changes: 9 additions & 1 deletion 11/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
WEBHOOK_CURL_OPTIONS = os.environ.get("WEBHOOK_CURL_OPTIONS") or ""
KEEP_BACKUP_DAYS = int(os.environ.get("KEEP_BACKUP_DAYS", 7))
FILENAME = os.environ.get("FILENAME", DB_NAME + "_%Y-%m-%d")
PG_DUMP_EXTRA_OPTIONS = os.environ.get("PG_DUMP_EXTRA_OPTIONS") or ""

file_name = dt.strftime(FILENAME)
backup_file = os.path.join(BACKUP_DIR, file_name)
Expand Down Expand Up @@ -69,7 +70,14 @@ def take_backup():
env.update({'PGPASSWORD': DB_PASS, 'PGHOST': DB_HOST, 'PGUSER': DB_USER, 'PGDATABASE': DB_NAME, 'PGPORT': DB_PORT})

# trigger postgres-backup
cmd("pg_dump -Fc > %s" % backup_file, env=env)
command = [
"pg_dump",
"-Fc",
]
if PG_DUMP_EXTRA_OPTIONS:
command.append(PG_DUMP_EXTRA_OPTIONS)
command.append("> %s" % backup_file)
cmd(" ".join(command), env=env)

def upload_backup():
opts = "--storage-class=%s %s" % (S3_STORAGE_CLASS, S3_EXTRA_OPTIONS)
Expand Down
2 changes: 1 addition & 1 deletion 11/restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def cmd(command, **kwargs):
sys.stderr.write("\n".join([
"Command execution failed. Output:",
"-"*80,
e.output,
e.output.decode(),
"-"*80,
""
]))
Expand Down
10 changes: 9 additions & 1 deletion 12/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
WEBHOOK_CURL_OPTIONS = os.environ.get("WEBHOOK_CURL_OPTIONS") or ""
KEEP_BACKUP_DAYS = int(os.environ.get("KEEP_BACKUP_DAYS", 7))
FILENAME = os.environ.get("FILENAME", DB_NAME + "_%Y-%m-%d")
PG_DUMP_EXTRA_OPTIONS = os.environ.get("PG_DUMP_EXTRA_OPTIONS") or ""

file_name = dt.strftime(FILENAME)
backup_file = os.path.join(BACKUP_DIR, file_name)
Expand Down Expand Up @@ -69,7 +70,14 @@ def take_backup():
env.update({'PGPASSWORD': DB_PASS, 'PGHOST': DB_HOST, 'PGUSER': DB_USER, 'PGDATABASE': DB_NAME, 'PGPORT': DB_PORT})

# trigger postgres-backup
cmd("pg_dump -Fc > %s" % backup_file, env=env)
command = [
"pg_dump",
"-Fc",
]
if PG_DUMP_EXTRA_OPTIONS:
command.append(PG_DUMP_EXTRA_OPTIONS)
command.append("> %s" % backup_file)
cmd(" ".join(command), env=env)

def upload_backup():
opts = "--storage-class=%s %s" % (S3_STORAGE_CLASS, S3_EXTRA_OPTIONS)
Expand Down
2 changes: 1 addition & 1 deletion 12/restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def cmd(command, **kwargs):
sys.stderr.write("\n".join([
"Command execution failed. Output:",
"-"*80,
e.output,
e.output.decode(),
"-"*80,
""
]))
Expand Down
10 changes: 9 additions & 1 deletion 13/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
WEBHOOK_CURL_OPTIONS = os.environ.get("WEBHOOK_CURL_OPTIONS") or ""
KEEP_BACKUP_DAYS = int(os.environ.get("KEEP_BACKUP_DAYS", 7))
FILENAME = os.environ.get("FILENAME", DB_NAME + "_%Y-%m-%d")
PG_DUMP_EXTRA_OPTIONS = os.environ.get("PG_DUMP_EXTRA_OPTIONS") or ""

file_name = dt.strftime(FILENAME)
backup_file = os.path.join(BACKUP_DIR, file_name)
Expand Down Expand Up @@ -69,7 +70,14 @@ def take_backup():
env.update({'PGPASSWORD': DB_PASS, 'PGHOST': DB_HOST, 'PGUSER': DB_USER, 'PGDATABASE': DB_NAME, 'PGPORT': DB_PORT})

# trigger postgres-backup
cmd("pg_dump -Fc > %s" % backup_file, env=env)
command = [
"pg_dump",
"-Fc",
]
if PG_DUMP_EXTRA_OPTIONS:
command.append(PG_DUMP_EXTRA_OPTIONS)
command.append("> %s" % backup_file)
cmd(" ".join(command), env=env)

def upload_backup():
opts = "--storage-class=%s %s" % (S3_STORAGE_CLASS, S3_EXTRA_OPTIONS)
Expand Down
2 changes: 1 addition & 1 deletion 13/restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def cmd(command, **kwargs):
sys.stderr.write("\n".join([
"Command execution failed. Output:",
"-"*80,
e.output,
e.output.decode(),
"-"*80,
""
]))
Expand Down
10 changes: 9 additions & 1 deletion 14/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
WEBHOOK_CURL_OPTIONS = os.environ.get("WEBHOOK_CURL_OPTIONS") or ""
KEEP_BACKUP_DAYS = int(os.environ.get("KEEP_BACKUP_DAYS", 7))
FILENAME = os.environ.get("FILENAME", DB_NAME + "_%Y-%m-%d")
PG_DUMP_EXTRA_OPTIONS = os.environ.get("PG_DUMP_EXTRA_OPTIONS") or ""

file_name = dt.strftime(FILENAME)
backup_file = os.path.join(BACKUP_DIR, file_name)
Expand Down Expand Up @@ -69,7 +70,14 @@ def take_backup():
env.update({'PGPASSWORD': DB_PASS, 'PGHOST': DB_HOST, 'PGUSER': DB_USER, 'PGDATABASE': DB_NAME, 'PGPORT': DB_PORT})

# trigger postgres-backup
cmd("pg_dump -Fc > %s" % backup_file, env=env)
command = [
"pg_dump",
"-Fc",
]
if PG_DUMP_EXTRA_OPTIONS:
command.append(PG_DUMP_EXTRA_OPTIONS)
command.append("> %s" % backup_file)
cmd(" ".join(command), env=env)

def upload_backup():
opts = "--storage-class=%s %s" % (S3_STORAGE_CLASS, S3_EXTRA_OPTIONS)
Expand Down
2 changes: 1 addition & 1 deletion 14/restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def cmd(command, **kwargs):
sys.stderr.write("\n".join([
"Command execution failed. Output:",
"-"*80,
e.output,
e.output.decode(),
"-"*80,
""
]))
Expand Down
10 changes: 9 additions & 1 deletion 15/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
WEBHOOK_CURL_OPTIONS = os.environ.get("WEBHOOK_CURL_OPTIONS") or ""
KEEP_BACKUP_DAYS = int(os.environ.get("KEEP_BACKUP_DAYS", 7))
FILENAME = os.environ.get("FILENAME", DB_NAME + "_%Y-%m-%d")
PG_DUMP_EXTRA_OPTIONS = os.environ.get("PG_DUMP_EXTRA_OPTIONS") or ""

file_name = dt.strftime(FILENAME)
backup_file = os.path.join(BACKUP_DIR, file_name)
Expand Down Expand Up @@ -69,7 +70,14 @@ def take_backup():
env.update({'PGPASSWORD': DB_PASS, 'PGHOST': DB_HOST, 'PGUSER': DB_USER, 'PGDATABASE': DB_NAME, 'PGPORT': DB_PORT})

# trigger postgres-backup
cmd("pg_dump -Fc > %s" % backup_file, env=env)
command = [
"pg_dump",
"-Fc",
]
if PG_DUMP_EXTRA_OPTIONS:
command.append(PG_DUMP_EXTRA_OPTIONS)
command.append("> %s" % backup_file)
cmd(" ".join(command), env=env)

def upload_backup():
opts = "--storage-class=%s %s" % (S3_STORAGE_CLASS, S3_EXTRA_OPTIONS)
Expand Down
2 changes: 1 addition & 1 deletion 15/restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def cmd(command, **kwargs):
sys.stderr.write("\n".join([
"Command execution failed. Output:",
"-"*80,
e.output,
e.output.decode(),
"-"*80,
""
]))
Expand Down
10 changes: 9 additions & 1 deletion 16/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
WEBHOOK_CURL_OPTIONS = os.environ.get("WEBHOOK_CURL_OPTIONS") or ""
KEEP_BACKUP_DAYS = int(os.environ.get("KEEP_BACKUP_DAYS", 7))
FILENAME = os.environ.get("FILENAME", DB_NAME + "_%Y-%m-%d")
PG_DUMP_EXTRA_OPTIONS = os.environ.get("PG_DUMP_EXTRA_OPTIONS") or ""

file_name = dt.strftime(FILENAME)
backup_file = os.path.join(BACKUP_DIR, file_name)
Expand Down Expand Up @@ -69,7 +70,14 @@ def take_backup():
env.update({'PGPASSWORD': DB_PASS, 'PGHOST': DB_HOST, 'PGUSER': DB_USER, 'PGDATABASE': DB_NAME, 'PGPORT': DB_PORT})

# trigger postgres-backup
cmd("pg_dump -Fc > %s" % backup_file, env=env)
command = [
"pg_dump",
"-Fc",
]
if PG_DUMP_EXTRA_OPTIONS:
command.append(PG_DUMP_EXTRA_OPTIONS)
command.append("> %s" % backup_file)
cmd(" ".join(command), env=env)

def upload_backup():
opts = "--storage-class=%s %s" % (S3_STORAGE_CLASS, S3_EXTRA_OPTIONS)
Expand Down
2 changes: 1 addition & 1 deletion 16/restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def cmd(command, **kwargs):
sys.stderr.write("\n".join([
"Command execution failed. Output:",
"-"*80,
e.output,
e.output.decode(),
"-"*80,
""
]))
Expand Down
2 changes: 1 addition & 1 deletion template/restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def cmd(command, **kwargs):
sys.stderr.write("\n".join([
"Command execution failed. Output:",
"-"*80,
e.output.decode("utf-8"),
e.output.decode(),
"-"*80,
""
]))
Expand Down

0 comments on commit 68cb99a

Please sign in to comment.