Save Database to Backblaze
- pg_dump - postgres database dumper, default with postgresql install
- 7z - 7zip file compress / decompression
apt install p7zip-full
- b2 - Backblaze b2 client from https://www.backblaze.com/b2/docs/quick_command_line.html
Note
Put b2 in common path so it is accessible e.g. /usr/bin
Execute as postgres user
- Create backup dir
mkdir -p /backups/db
- Get script
mkdir ~/bin
cd ~/bin
wget https://raw.githubusercontent.com/ninja-software/savedbb/master/savedbb.sh
chmod +x savedbb.sh
- Download, set permission, edit .savedbb.env file
cd ~
wget -O .savedbb.env https://raw.githubusercontent.com/ninja-software/savedbb/master/.savedbb.sample.env
chmod 600 .savedbb.env
nano .savedbb.env
- Run as cron job (as postgres user, otherwise need to specify user in pg_dump)
crontab -e
# m h dom mon dow command
0 10 * * * . $HOME/.savedbb.env; $HOME/bin/savedbb.sh >> $HOME/bkup.log