#!/bin/bash backup_directory="/var/backups/synapse_backups" timestamp=$(date +"%Y-%m-%d_%H:%M") # Create backup directory if not present if [ ! -d $backup_directory ]; then mkdir -p $backup_directory; fi # Create a database dump and compress it nice -n 19 docker exec matrix-postgres-1 pg_dump postgres://synapse@localhost:5432/synapse | nice -n 19 xz -T1 -1 > $backup_directory/synapse-postgres-$timestamp.sql.xz # Delete backups older than one week find $backup_directory -mtime +7 -exec rm {} \; exit 0