DAViCal automated backup

This little script automates the dump of your DAViCal database :

#!/bin/sh

PATH=/bin:/usr/bin
export PATH

backup_location=/data/backups/davical

now=`date “+%Y.%m.%d_%H.%M.%S”`
backup_file=$backup_location/davical_$now.pgdump

su – postgres -c “pg_dump -Fc davical > $backup_file”
gzip $backup_file

# remove old backups
find $backup_location -type f -name “davical_*.pgdump.gz” -mtime +30 -exec rm {} \;

exit 0

Install it as /etc/cron.daily/davical_backup on your Linux box.

To restore your database after a disaster, use this :

createdb –owner davical_dba –encoding UTF8 –template template0 davical
pg_restore -Fc -d davical davical.pgdump

Trackbacks & Pingbacks 1

  1. From ДАВАЙ-ДАВАЙ - client-side backup of CALDAV calendars on 04 Feb 2010 at 17:34

    [...] recently published a server-side script to backup all calendars stored in a Davical server. On request and idea of [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

Powered by WP Hashcash