Skip to content

Commit 818828d

Browse files
author
a.b.christie
committed
fix: Backups now correctly found in /backup root directory
1 parent a89b33e commit 818828d

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

sql-recovery/docker-entrypoint.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ if [ -v BACKUP_VOLUME_IS_S3 ]; then
6060
S3FS_EXTRA_OPTIONS+=" -o ${BACKUP_VOLUME_S3_REQUEST_STYLE}"
6161
fi
6262

63-
# Create the target directory ('/recovery')
63+
# Create the target directory ('/backup')
6464
# and then invoke s3fs
6565
mkdir -p /backup
6666
S3FS_CMD_OPTIONS="-o passwd_file=/tmp/.passwd-s3fs ${S3FS_EXTRA_OPTIONS}"
6767
echo "--] s3fs AWS_BUCKET_NAME=${AWS_BUCKET_NAME}"
6868
echo "--] s3fs S3FS_CMD_OPTIONS=${S3FS_CMD_OPTIONS}"
69-
s3fs ${AWS_BUCKET_NAME} /recovery ${S3FS_CMD_OPTIONS}
69+
s3fs ${AWS_BUCKET_NAME} /backup ${S3FS_CMD_OPTIONS}
7070

7171
# And then wait (to avoid weird /backup root directories not existing)
7272
echo "--] Sleeping for 4 seconds..."

sql-recovery/recovery.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@
202202
# Do not stop on error?
203203
DO_NOT_STOP_ON_ERROR = os.environ.get('DO_NOT_STOP_ON_ERROR', '')
204204

205+
# The backup root (where backups can be found)
206+
BACKUP_ROOT_DIR = '/backup'
205207
# The recovery root dir, where backups are unpacked.
206208
RECOVERY_ROOT_DIR = '/recovery'
207209
DECOMPRESSED_RECOVERY_NAME = 'recovery'
@@ -397,6 +399,9 @@ def error(error_no):
397399
if not os.path.isdir(RECOVERY_ROOT_DIR):
398400
print('--] Recovery root directory does not exist (%s). Leaving.' % RECOVERY_ROOT_DIR)
399401
error(ERROR_NO_ROOT)
402+
if not os.path.isdir(BACKUP_ROOT_DIR):
403+
print('--] Backup root directory does not exist (%s). Leaving.' % BACKUP_ROOT_DIR)
404+
error(ERROR_NO_ROOT)
400405

401406
#####
402407
# 1 #
@@ -405,7 +410,7 @@ def error(error_no):
405410
RCLONE_START_TIME = datetime.now()
406411
print('--] Running rclone [%s]' % RCLONE_START_TIME)
407412

408-
RCLONE_CMD = 'rclone sync remote:%s %s' % (USE_RCLONE_BUCKET_AND_PATH, RECOVERY_ROOT_DIR)
413+
RCLONE_CMD = 'rclone sync remote:%s %s' % (USE_RCLONE_BUCKET_AND_PATH, BACKUP_ROOT_DIR)
409414
print(" $", RCLONE_CMD)
410415

411416
COMPLETED_PROCESS = subprocess.run(RCLONE_CMD, shell=True,
@@ -430,7 +435,7 @@ def error(error_no):
430435
# A dictionary of backup files and their directories.
431436
LATEST_BACKUP = None
432437
KNOWN_BACKUPS = {}
433-
FILE_SEARCH = os.path.join(RECOVERY_ROOT_DIR, '**', BACKUP_FILE_PREFIX + '*')
438+
FILE_SEARCH = os.path.join(BACKUP_ROOT_DIR, '**', BACKUP_FILE_PREFIX + '*')
434439
BACKUPS = glob.glob(FILE_SEARCH)
435440
for BACKUP in BACKUPS:
436441
FILENAME = os.path.basename(BACKUP)
@@ -542,8 +547,6 @@ def error(error_no):
542547
if COMPLETED_PROCESS.stderr:
543548
print('--] stderr follows...')
544549
print(COMPLETED_PROCESS.stderr.decode("utf-8").strip())
545-
# Remove the current backup
546-
os.remove(BACKUP)
547550
print('--] Leaving')
548551
write_termination_message('Unpack failed')
549552
sys.exit(0)

0 commit comments

Comments
 (0)