Advertisement
Guest User

Untitled

a guest
Feb 1st, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #!/bin/sh
  2. remote_user=root
  3. remote_address=12.34.56.78
  4. mysql_password=password
  5. mysql_database=fume
  6. dump_target="~/fume_backup/$(date +%s)_fume_backup.sql"
  7. dump_destination="/cygdrive/y/Dropbox/Scripts/fume_backup"
  8.  
  9. ssh="ssh $remote_user@$remote_address"
  10.  
  11. $ssh "mkdir -p ~/fume_backup"
  12.  
  13. $ssh "mysqldump -u root -p$mysql_password $mysql_database > $dump_target"
  14. scp $remote_user@$remote_address:$dump_target $dump_destination
  15.  
  16. # clean up
  17. $ssh "rm $dump_target"
  18.  
  19. # keep only the latest 5 dumps
  20. (cd $dump_destination && ls -t | tail -n +6 | xargs rm)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement