Last active
August 29, 2015 14:26
-
-
Save tiagoameller/3e24e4c6047baeff38b8 to your computer and use it in GitHub Desktop.
automatic backup for rails postgres database
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 | |
| # Please see some environment variables must be declared outside this script | |
| # To execute this script every six hours, put in your crontab -e | |
| # m h dom mon dow command | |
| # 0 */6 * * * /home/rails/pn_backup.sh | |
| BackupHome=/home/rails/pn_backup/ | |
| BackupBase=`date +%Y-%m-%dT%H%M` | |
| BackupFile="$BackupBase".sql | |
| BackupZip="$BackupBase".tar.gz | |
| cd $BackupHome | |
| pg_dump pounou_production > $BackupFile | |
| tar cvfz $BackupZip $BackupFile | |
| rm $BackupFile | |
| ftp -n -v $FTP_HOST << EOT | |
| user $FTP_USER $FTP_PASSW | |
| put $BackupZip | |
| bye | |
| EOT | |
| cd - |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment