freifunk-berlin / puppet

Deprecated: New infrastructure development is happening in https://github.com/freifunk-berlin/ansible
Other
2 stars 4 forks source link

remove old database backups from config.berlin.freifunk.net #29

Closed booo closed 8 years ago

booo commented 9 years ago

At the moment we create database "backups" with the script in /etc/cron.daily/postgres-backup. Functionality that removes old backups is missing which is a problem.

booo commented 8 years ago

Current backup script:

#!/bin/bash

DATABASES="wizard nipap ca"
BACKUP_DIR=/root/postgres-backups
DATE=$(date +"%Y%m%d")
USER=postgres

for database in $DATABASES; do
        path="${BACKUP_DIR}/$database-${DATE}.sql"
        su -l -c "pg_dump ${database}" $USER > $path
done

# remove all backups older then one week
/usr/bin/find ${BACKUP_DIR} -mtime +7 -name "*.sql" -print -exec /bin/rm {} \;

#TODO backup on another machine

Should be done.