Skip to content

Commit 6edfc06

Browse files
authored
Merge pull request #2 from allonhadaya/backup-cleanup
Backup cleanup
2 parents 36fde6e + 5f27d1b commit 6edfc06

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

template/ubuntu-16.04/backup.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ mkdir ${BACKUP_DIR}
1212
cd ${BACKUP_DIR}
1313

1414
# Delete the oldest files by only listing out everything older than the newest 7 files
15-
ls *.gz.enc | sort | tail -n +7 | xargs rm
16-
ls *.gz.passphrase.enc | sort | tail -n +7 | xargs rm
15+
ls *.tar.gz.enc | sort | tail -n +7 | xargs rm
16+
ls *.passphrase.enc | sort | tail -n +7 | xargs rm
1717

1818
# Backup the MySQL databases
1919
mysqldump -u<username> -p<password> production > production.sql
@@ -28,10 +28,10 @@ openssl rand 32 -out ${BACKUP_PASSPHRASE_FILE}
2828
openssl enc -aes-256-cbc -pass file:${BACKUP_PASSPHRASE_FILE} < ${BACKUP_FILE} > ${BACKUP_FILE_ENCRYPTED}
2929

3030
# Encrypt the passphrase
31-
openssl rsautl -encrypt -pubin -inkey ~/public-key.pem < ${BACKUP_PASSPHRASE_FILE} > ${BACKUP_PASSPHRASE_FILE_ENCRYPTED}
31+
openssl rsautl -encrypt -pubin -inkey /root/public-key.pem < ${BACKUP_PASSPHRASE_FILE} > ${BACKUP_PASSPHRASE_FILE_ENCRYPTED}
3232

3333
# Clean up
34-
rm ${BACKUP_FILE} ${BACKUP_PASSPHRASE_FILE}
34+
rm ${BACKUP_FILE} ${BACKUP_PASSPHRASE_FILE} *.sql
3535

3636
# Copy offsite
3737
#scp ${BACKUP_FILE_ENCRYPTED} ${BACKUP_PASSPHRASE_FILE_ENCRYPTED} <username>@<backup-server>:backups/.

0 commit comments

Comments
 (0)