mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Adding postgres backup script.
This commit is contained in:
parent
8da2ca00d3
commit
da48e2d0d0
2 changed files with 29 additions and 3 deletions
|
@ -23,9 +23,7 @@ do_backup(){
|
|||
# ${MONGODB_SHELL} admin fsync_lock.js
|
||||
for collection in $COLLECTIONS
|
||||
do
|
||||
cmd="${DUMP_UTILITY} --db ${DB_NAME} --collection $collection -o ${dir_name} "
|
||||
echo $cmd
|
||||
`$cmd`
|
||||
${DUMP_UTILITY} --db ${DB_NAME} --collection $collection -o ${dir_name}
|
||||
done
|
||||
tar -jcf $file_name ${dir_name}
|
||||
# ${MONGODB_SHELL} admin fsync_unlock.js
|
||||
|
|
28
utils/backups/postgresql_backup.sh
Normal file
28
utils/backups/postgresql_backup.sh
Normal file
|
@ -0,0 +1,28 @@
|
|||
#!/bin/sh
|
||||
|
||||
DB_NAME='newsblur'
|
||||
date_now=`date +%Y_%m_%d_%H_%M`
|
||||
file_name='backup_postgresql_'${date_now}'.sql.gz'
|
||||
|
||||
log() {
|
||||
echo $1
|
||||
}
|
||||
|
||||
do_cleanup(){
|
||||
sudo su postgres -c "rm ~/${file_name}"
|
||||
log 'cleaning up....'
|
||||
}
|
||||
|
||||
do_backup(){
|
||||
log 'snapshotting the db and creating archive'
|
||||
sudo su postgres -c "time pg_dump ${DB_NAME} | gzip -c > ~/${file_name}"
|
||||
log 'data backd up and created snapshot'
|
||||
}
|
||||
|
||||
save_in_s3(){
|
||||
log 'saving the psql backup archive in amazon S3' && \
|
||||
python s3.py set ${file_name} && \
|
||||
log 'data backup saved in amazon s3'
|
||||
}
|
||||
|
||||
do_backup && save_in_s3 && do_cleanup
|
Loading…
Add table
Reference in a new issue