update and cleanup

This commit is contained in:
2024-02-09 22:15:49 +01:00
parent a85701eee2
commit a315989db1
5 changed files with 26 additions and 101 deletions

17
borg-postgresql-backup.sh Normal file
View 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