From 174c72eb701bfbefb23c8b7e61674d5ec79c4b8d Mon Sep 17 00:00:00 2001 From: Micke Nordin Date: Tue, 12 Sep 2023 16:19:17 +0200 Subject: [PATCH] BACKUPDB: Fix bug that put backup in a file instead of a directory We found a bug that moved the backups to a file, but we want that to be a directory, meaning that all the files were overwritten one by one, and we were not taking the backups as we though. --- templates/script/backupdb.erb.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/templates/script/backupdb.erb.sh b/templates/script/backupdb.erb.sh index 1eb7992..c83abac 100644 --- a/templates/script/backupdb.erb.sh +++ b/templates/script/backupdb.erb.sh @@ -14,8 +14,6 @@ if ! [[ ${backup} =~ backup1.*sunet.se$ ]]; then echo "Example: ${0} backup1.sunet.drive.sunet.se" fi backup_dir="/opt/backups" -backup_dir_long="${backup_dir}/backups" -mkdir -p ${backup_dir} bucket="db-backups" mirror="<%= @customer %>-<%= @environment %>-mirror" if [[ ${mirror} =~ common-(test|prod)-mirror ]]; then @@ -23,12 +21,13 @@ if [[ ${mirror} =~ common-(test|prod)-mirror ]]; then bucket="${bucket}-${suffix}" backup_dir="${backup_dir}-${suffix}" fi +mkdir -p ${backup_dir} echo "Backing up database for ${backup}" ssh ${backup} "sudo /home/script/bin/backup_db.sh" echo "Cleaning up old backups for ${backup}" ssh ${backup} "sudo /home/script/bin/purge_backups.sh /opt/mariadb_backup/backups/" echo "Copying backups here" -scp script@${backup}:/opt/mariadb_backup/backups/$(date +%Y/%m/%d)/*.gz ${backup_dir_long} +scp script@${backup}:/opt/mariadb_backup/backups/$(date +%Y/%m/%d)/*.gz ${backup_dir} echo "Copying backups to remote bucket" rclone mkdir ${mirror}:${bucket} duplicity --full-if-older-than 1M --tempdir /mnt --archive-dir /mnt --no-encryption ${backup_dir} rclone://${mirror}:/${bucket}