update and cleanup
This commit is contained in:
17
borg-postgresql-backup.sh
Normal file
17
borg-postgresql-backup.sh
Normal file
@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Borg repo location
|
||||
REPOSITORY=/var/backup/database.borg/
|
||||
# Example of remote repo
|
||||
# REPOSITORY=ssh://backuper@192.168.1.100/var/backup/database.borg/
|
||||
|
||||
# Dump all postgres databases to file
|
||||
sudo -u postgres pg_dumpall > /tmp/posgresql.sql
|
||||
# Backup the sql file
|
||||
borg create -v --stats --compression zlib,6 $REPOSITORY::$(date +%Y-%m-%d-%H:%M) /tmp/posgresql.sql
|
||||
rm /tmp/posgresql.sql
|
||||
# Delete old backups
|
||||
borg prune -v $REPOSITORY --keep-daily=3 --keep-weekly=2 --keep-monthly=12
|
||||
echo "`date +[%F/%T]` Done!"
|
||||
|
||||
exit
|
Reference in New Issue
Block a user