Skip to content

Instantly share code, notes, and snippets.

@clintliang
Last active August 16, 2017 18:18
Show Gist options
  • Save clintliang/c6e4fdade6ff39600a56c696aa29b729 to your computer and use it in GitHub Desktop.
Save clintliang/c6e4fdade6ff39600a56c696aa29b729 to your computer and use it in GitHub Desktop.
# !/bin/bash
backup_dir=""
#String to append to the name of the backup files
backup_date=`date +%d-%m-%Y`
db=""
#Numbers of days you want to keep copie of your databases
pg_dump -b --data-only -T '"SequelizeMeta"' $db>$backup_dir/$db\_$backup_date.sql
# Numbers of days you want to keep the dumps
number_of_days=7
find $backup_dir -type f -name "*.sql" -prune -mtime +$number_of_days -exec rm -f {} \;
# !/bin/bash
backup_dir=""
# Numbers of days you want to keep the dumps
number_of_days=7
find $backup_dir -type f -name "*.sql" -prune -mtime +$number_of_days -exec rm -f {} \;
# !/bin/bash
backup_dir=""
key_dir=""
remote_backup_dir="username@hostname:dir/"
rsync -avz -e "ssh -i $key_dir" $backup_dir/*.sql $remote_backup_dir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment