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.
This commit is contained in:
parent
b989bd3d54
commit
174c72eb70
|
@ -14,8 +14,6 @@ if ! [[ ${backup} =~ backup1.*sunet.se$ ]]; then
|
||||||
echo "Example: ${0} backup1.sunet.drive.sunet.se"
|
echo "Example: ${0} backup1.sunet.drive.sunet.se"
|
||||||
fi
|
fi
|
||||||
backup_dir="/opt/backups"
|
backup_dir="/opt/backups"
|
||||||
backup_dir_long="${backup_dir}/backups"
|
|
||||||
mkdir -p ${backup_dir}
|
|
||||||
bucket="db-backups"
|
bucket="db-backups"
|
||||||
mirror="<%= @customer %>-<%= @environment %>-mirror"
|
mirror="<%= @customer %>-<%= @environment %>-mirror"
|
||||||
if [[ ${mirror} =~ common-(test|prod)-mirror ]]; then
|
if [[ ${mirror} =~ common-(test|prod)-mirror ]]; then
|
||||||
|
@ -23,12 +21,13 @@ if [[ ${mirror} =~ common-(test|prod)-mirror ]]; then
|
||||||
bucket="${bucket}-${suffix}"
|
bucket="${bucket}-${suffix}"
|
||||||
backup_dir="${backup_dir}-${suffix}"
|
backup_dir="${backup_dir}-${suffix}"
|
||||||
fi
|
fi
|
||||||
|
mkdir -p ${backup_dir}
|
||||||
echo "Backing up database for ${backup}"
|
echo "Backing up database for ${backup}"
|
||||||
ssh ${backup} "sudo /home/script/bin/backup_db.sh"
|
ssh ${backup} "sudo /home/script/bin/backup_db.sh"
|
||||||
echo "Cleaning up old backups for ${backup}"
|
echo "Cleaning up old backups for ${backup}"
|
||||||
ssh ${backup} "sudo /home/script/bin/purge_backups.sh /opt/mariadb_backup/backups/"
|
ssh ${backup} "sudo /home/script/bin/purge_backups.sh /opt/mariadb_backup/backups/"
|
||||||
echo "Copying backups here"
|
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"
|
echo "Copying backups to remote bucket"
|
||||||
rclone mkdir ${mirror}:${bucket}
|
rclone mkdir ${mirror}:${bucket}
|
||||||
duplicity --full-if-older-than 1M --tempdir /mnt --archive-dir /mnt --no-encryption ${backup_dir} rclone://${mirror}:/${bucket}
|
duplicity --full-if-older-than 1M --tempdir /mnt --archive-dir /mnt --no-encryption ${backup_dir} rclone://${mirror}:/${bucket}
|
||||||
|
|
Loading…
Reference in a new issue