Advertisement
Andrea_N

Bash Backup

Feb 24th, 2015
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.58 KB | None | 0 0
  1. #!/bin/bash
  2. day=$(date +%F)
  3. #folder where is the backup
  4. Folder="/home/teamportal/data/filestorage/www/_cron_db_bak"
  5. #file to create
  6. File="/root/backup/$day.tar"
  7. #tmp folder for another script ftp copy  
  8. Folder2="/root/temporanea"
  9. #find 1 day old file and copy to the ftp folder
  10. find $Folder -iname "*.backup" -mtime -1 -print0 | xargs -0 -r -I file cp -v -p file $Folder2
  11. #create tar
  12. tar cvf $File $Folder2
  13. #send it via mutt
  14. cat /home/mailmessage.txt |mutt -a $File -s "BACKUP Database" -- your-mail@gmail.com
  15. #remove 90+ days old file
  16. find $File* -mtime +90 -exec rm {} \;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement