postgres backup to b2 upload

added script for taking daily dumps of postgres running in docker, uploading them to a b2 bucket, and deleting the local file
This commit is contained in:
Siddhartha 2022-07-19 20:53:09 +05:30
parent cf58275bf3
commit 5927a74384
2 changed files with 31 additions and 6 deletions

31
postgres-dump-backup.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/bash
echo "Creating postgres database dumps..."
CURRENTDATETIME=`date +"%Y-%m-%d_%H_%M_%S"`
FILENAME_WITH_DIR="/home/ubuntu/backups/postgres/dump_"$CURRENTDATETIME
FILENAME="dump_"$CURRENTDATETIME
/usr/bin/docker exec -t postgres pg_dumpall -c -U one800 > $FILENAME_WITH_DIR.sql
if [ $? -eq 0 ]; then
echo "dump created successfully!"
else
echo "dump failed!"
fi
echo "Uploading to b2..."
/usr/local/bin/b2 upload-file one800-backups $FILENAME_WITH_DIR.sql postgres/db-dumps/$FILENAME.sql --noProgress --quiet
if [ $? -eq 0 ]; then
echo "dump uploaded to b2 successfully!"
echo "removing the local dump file..."
sleep 2
rm $FILENAME_WITH_DIR.sql
echo "removed the local dump file successfully!"
else
echo "dump upload to b2 failed!"
fi

View File

@ -1,6 +0,0 @@
# Activate mouse in tmux window/pane
set -g mouse on
# Taken up from this answer: https://unix.stackexchange.com/questions/145857/how-do-you-hide-a-tmux-pane/506103#506103
bind ! break-pane -d -n _hidden_name
bind @ join-pane -s $.0