-
-
Save redlotus/d6ff84c0e9c618537027cf88a265fa74 to your computer and use it in GitHub Desktop.
Revisions
-
sirbrillig revised this gist
Jan 24, 2013 . 1 changed file with 8 additions and 11 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -5,27 +5,24 @@ BACKUP_DIR=/pg_backup DAYS_TO_KEEP=14 FILE_SUFFIX=_pg_backup.sql DATABASE= USER=postgres FILE=`date +"%Y%m%d%H%M"`${FILE_SUFFIX} OUTPUT_FILE=${BACKUP_DIR}/${FILE} # do the database backup (dump) # use this command for a database server on localhost. add other options if need be. pg_dump -U ${USER} ${DATABASE} -F p -f ${OUTPUT_FILE} # gzip the mysql database dump file gzip $OUTPUT_FILE # show the user the result echo "${OUTPUT_FILE}.gz was created:" ls -l ${OUTPUT_FILE}.gz # prune old backups find $BACKUP_DIR -maxdepth 1 -mtime +$DAYS_TO_KEEP -name "*${FILE_SUFFIX}.gz" -exec rm -rf '{}' ';' -
sirbrillig revised this gist
Jan 24, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ BACKUP_DIR=/pg_backup DAYS_TO_KEEP=14 FILE=`date +"%Y%m%d%H%M"`_pg_backup.sql DATABASE= USER=postgres -
sirbrillig revised this gist
Jan 24, 2013 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ #!/bin/bash # # Backup a Postgresql database into a daily file. # -
sirbrillig revised this gist
Jan 24, 2013 . 1 changed file with 19 additions and 14 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,25 +1,30 @@ # # Backup a Postgresql database into a daily file. # BACKUP_DIR=/pg_backup DAYS_TO_KEEP=14 FILE=`date +"%Y%m%d"`_pg_backup.sql DATABASE= USER=postgres OUTPUT_FILE=${BACKUP_DIR}/${FILE} # (2) in case you run this twice in one day, remove the previous version of the file unalias rm 2> /dev/null rm ${OUTPUT_FILE} 2> /dev/null rm ${OUTPUT_FILE}.gz 2> /dev/null # (3) do the database backup (dump) # use this command for a database server on localhost. add other options if need be. pg_dump -U ${USER} ${DATABASE} -F p -f ${OUTPUT_FILE} # (4) gzip the mysql database dump file gzip $OUTPUT_FILE # (5) show the user the result echo "${OUTPUT_FILE}.gz was created:" ls -l ${OUTPUT_FILE}.gz # (6) prune old backups find $BACKUP_DIR -maxdepth 1 -mtime +$DAYS_TO_KEEP -name "*-pg_backup.sql.gz" -exec rm -rf '{}' ';' -
dangerousbeans renamed this gist
Sep 30, 2011 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
dangerousbeans created this gist
Sep 30, 2011 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ FILE=`date +"%Y%m%d"`_backup.sql DBSERVER=127.0.0.1 DATABASE= USER=postgres PASS= # (2) in case you run this twice in one day, remove the previous version of the file unalias rm 2> /dev/null rm ${FILE} 2> /dev/null rm ${FILE}.gz 2> /dev/null # (3) do the mysql database backup (dump) # use this command for a database server on a separate host: #mysqldump --opt --protocol=TCP --user=${USER} --password=${PASS} --host=${DBSERVER} ${DATABASE} > ${FILE} # use this command for a database server on localhost. add other options if need be. pg_dump ${DATABASE} > ${FILE} # (4) gzip the mysql database dump file gzip $FILE # (5) show the user the result echo "${FILE}.gz was created:" ls -l ${FILE}.gz