diff --git a/template/ubuntu-16.04/backup.sh b/template/ubuntu-16.04/backup.sh index 4c9ed17..cd83273 100644 --- a/template/ubuntu-16.04/backup.sh +++ b/template/ubuntu-16.04/backup.sh @@ -12,8 +12,8 @@ mkdir ${BACKUP_DIR} cd ${BACKUP_DIR} # Delete the oldest files by only listing out everything older than the newest 7 files -ls *.gz.enc | sort | tail -n +7 | xargs rm -ls *.gz.passphrase.enc | sort | tail -n +7 | xargs rm +ls *.tar.gz.enc | sort | tail -n +7 | xargs rm +ls *.passphrase.enc | sort | tail -n +7 | xargs rm # Backup the MySQL databases mysqldump -u -p production > production.sql @@ -28,10 +28,10 @@ openssl rand 32 -out ${BACKUP_PASSPHRASE_FILE} openssl enc -aes-256-cbc -pass file:${BACKUP_PASSPHRASE_FILE} < ${BACKUP_FILE} > ${BACKUP_FILE_ENCRYPTED} # Encrypt the passphrase -openssl rsautl -encrypt -pubin -inkey ~/public-key.pem < ${BACKUP_PASSPHRASE_FILE} > ${BACKUP_PASSPHRASE_FILE_ENCRYPTED} +openssl rsautl -encrypt -pubin -inkey /root/public-key.pem < ${BACKUP_PASSPHRASE_FILE} > ${BACKUP_PASSPHRASE_FILE_ENCRYPTED} # Clean up -rm ${BACKUP_FILE} ${BACKUP_PASSPHRASE_FILE} +rm ${BACKUP_FILE} ${BACKUP_PASSPHRASE_FILE} *.sql # Copy offsite #scp ${BACKUP_FILE_ENCRYPTED} ${BACKUP_PASSPHRASE_FILE_ENCRYPTED} @:backups/.