Organizing Backup scripts

This commit is contained in:
Bruno F. Fontes 2019-07-15 13:30:28 -03:00
parent dd5170b3b1
commit 428fe8ce78
Signed by: brunofontes
GPG Key ID: EE3447CE80048495
6 changed files with 25 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
.localBackupPath
.serverBackupPath
.sshKeyBackupPath
.sshKey

View File

@ -0,0 +1 @@
/my/local/backup

View File

@ -0,0 +1 @@
sshBackupUser@serverIp:/my/backup/path

View File

@ -0,0 +1 @@
/home/myUser/.ssh/id_rsa_backup

9
Services/backup-db.sh Executable file
View File

@ -0,0 +1,9 @@
#! /bin/bash
sshKey=$(<.sshKey)
serverBackupPath=$(<.serverBackupPath)
localPath=$(<.localBackupPath)
/bin/rsync -r -e "ssh -i $sshKey" "$serverBackupPath/db/*" "$localPath/db/"
# Delete files older than 15 days
find "$localPath/db" -type f -name "*.sql.gz" -mtime +15 -delete

9
Services/backup-files.sh Executable file
View File

@ -0,0 +1,9 @@
#! /bin/bash
sshKey=$(<.sshKey)
serverBackupPath=$(<.serverBackupPath)
localPath=$(<.localBackupPath)
/bin/rsync -r -e "ssh -i $sshKey" "$serverBackupPath/files/*" "$localPath/files/"
# Delete files older than 30 days
find "$localPath/files" -type f -name "*.*" -mtime +30 -delete