mirror of
https://github.com/brunofontes/linuxShortcuts.git
synced 2024-11-24 00:50:51 +00:00
Organizing Backup scripts
This commit is contained in:
parent
dd5170b3b1
commit
428fe8ce78
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
.localBackupPath
|
||||||
|
.serverBackupPath
|
||||||
|
.sshKeyBackupPath
|
||||||
|
.sshKey
|
1
Services/.localBackupPath_TEMPLATE
Normal file
1
Services/.localBackupPath_TEMPLATE
Normal file
@ -0,0 +1 @@
|
|||||||
|
/my/local/backup
|
1
Services/.serverBackupPath_TEMPLATE
Normal file
1
Services/.serverBackupPath_TEMPLATE
Normal file
@ -0,0 +1 @@
|
|||||||
|
sshBackupUser@serverIp:/my/backup/path
|
1
Services/.sshKey_TEMPLATE
Normal file
1
Services/.sshKey_TEMPLATE
Normal file
@ -0,0 +1 @@
|
|||||||
|
/home/myUser/.ssh/id_rsa_backup
|
9
Services/backup-db.sh
Executable file
9
Services/backup-db.sh
Executable 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
9
Services/backup-files.sh
Executable 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
|
Loading…
Reference in New Issue
Block a user