Organizing VPS backup

This commit is contained in:
Bruno F. Fontes 2019-10-13 11:07:14 -03:00
parent 8f16048878
commit 6093a485a2
Signed by: brunofontes
GPG Key ID: EE3447CE80048495
8 changed files with 17 additions and 42 deletions

View File

@ -1,5 +0,0 @@
[Unit]
Description=Backup contabo db daily
[Service]
ExecStart=/home/bruno/Backups/Contabo/backup-db.sh

View File

@ -1,10 +0,0 @@
[Unit]
Description=Backup contabo db daily
[Timer]
Persistent=true
OnCalendar=*-*-* 10:00:00
WakeSystem=true
[Install]
WantedBy=timers.target

View File

@ -1,5 +0,0 @@
[Unit]
Description=Backup contabo files once per week
[Service]
ExecStart=/home/bruno/Backups/Contabo/backup-files.sh

View File

@ -0,0 +1,5 @@
[Unit]
Description=Backup contabo daily
[Service]
ExecStart=/home/bruno/Backups/Contabo/backup-contabo.sh

10
Services/backup-contabo.sh Executable file
View File

@ -0,0 +1,10 @@
#! /bin/bash
sleep 60
/bin/rsync -a -e "ssh -i /home/bruno/.ssh/id_rsa_backup" mybackup@167.86.78.36:/home/bruno/backups/* /home/bruno/Backups/Contabo/
# Delete old backups
find /home/bruno/Backups/Contabo/db -type f -name "*.sql.gz" -mtime +15 -delete
find /home/bruno/Backups/Contabo/files -type f -name "*.*" -mtime +35 -delete
find /home/bruno/Backups/Contabo/vmail -type f -name "*.*" -mtime +20 -delete
find /home/bruno/Backups/Contabo/ -type f -name "*.*" -mtime +120 -delete

View File

@ -1,9 +1,9 @@
[Unit]
Description=Backup contabo files once per week
Description=Backup contabo daily
[Timer]
Persistent=true
OnCalendar=*-*-* 10:03:00
OnCalendar=*-*-* 10:15:00
WakeSystem=true
#DayOfWeek Year-Month-Day Hour:Minute:Second

View File

@ -1,10 +0,0 @@
#! /bin/bash
sleep 50
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

View File

@ -1,10 +0,0 @@
#! /bin/bash
sleep 60
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