Created
September 13, 2017 18:07
-
-
Save ilfuriano/7b163ea22e2ed94d4967256bead5c1f7 to your computer and use it in GitHub Desktop.
Backup Postgres DB to Google Drive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
now=`date +%Y%m%d-%H%M%S` | |
day_ago=7 | |
db_name="DB_NAME" | |
base_path="BASE_PATH" | |
dump_fpath="$base_path/backup_db-$now.sql.gz" | |
sudo -u postgres pg_dump $db_name | gzip -9 > $dump_fpath | |
find $base_path -maxdepth 1 -type f -name "backup_db*.tar" -mtime +$day_ago -delete | |
# https://github.com/prasmussen/gdrive | |
gdrive sync upload $base_path GDRIVE_FOLDER_ID |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment