Last active
August 27, 2020 01:49
-
-
Save hello-alf/898a57dead64f1d2fc279d8f083c9bb7 to your computer and use it in GitHub Desktop.
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
1. create a folder called Backups | |
mkdir Backups | |
2. Login as postgres user through console | |
sudo -su postgres | |
3. execute the following comand | |
./backup_script.sh | |
(REPLACE DB_NAME with the database that you want to extract data) | |
NOTE: the content of backup_script is: | |
#!/bin/bash | |
# | |
# Takes a full backup of the database and stores it in the backup folder | |
# Run this script as the postgres user | |
# | |
DATE=`date +%Y-%m-%d` | |
#echo `date` - Delete old backups | |
#find ~/Backups/* -mtime +1 -delete | |
echo `date` - Do a full postgres DB_NAME dump | |
pg_dump sipos| gzip > ~/Backups/db_backup_$DATE.gz | |
echo `date` - Backup complete |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment