Skip to content

Instantly share code, notes, and snippets.

@kfreiman
Created February 25, 2016 09:57
Show Gist options
  • Save kfreiman/a83b8fd83cfaf3fea581 to your computer and use it in GitHub Desktop.
Save kfreiman/a83b8fd83cfaf3fea581 to your computer and use it in GitHub Desktop.
MySQL dump, send to another server and clean old files script
mysqldump -uuser -ppass -hhost basename | gzip > `date +/local/path/%Y%m%d.%H%M%S.sql.gz`
sshpass -p "pass" rsync -r /local/path/ remoteuser@host:/remote/path
find /local/path -name "*.sql.gz" -mtime +7 -exec rm {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment