[Owncloud] Backup Owncloud Data, Calendars, and Contacts
owncloud_mailing_list at status.e4ward.com
owncloud_mailing_list at status.e4ward.com
Wed Jun 5 13:18:29 UTC 2013
Thanks Bruno!
One clarification: saving the database obviously doesn't save the data
(i.e. files), but does it save every user's calendar and contacts? I
guess I sort of thought the database was really only a indexer.
Kyle
On Wed, Jun 5, 2013 at 1:57 AM, Bruno Flückiger <bruno at bsdhowto.ch> wrote:
> On 05.06.2013 01:38, owncloud_mailing_list at status.e4ward.com wrote:
>>
>> Hello all.
>
>
> Hi Kyle
>
>
>> I've seen a few mentions of this here and there, but nothing very
>> well documented and most of it pretty old.
>>
>> I have a home server I've using to serve up owncloud (using mysql). I
>> also have an external RAID storage device. I would like to
>> periodically backup owncloud's data, calendars, and contacts for ALL
>> users onto this external device. The data is easy since its held in a
>> file structure, but what about calendars and contacts? How do I back
>> them up and easily re-import them? The "Export this ownCloud instance"
>> bit in the admin settings says it can export user data, database and
>> system files. But how does this work, and does it also export
>> calendars and contacts? How do I re-import them?
>
>
> I use mysqldump in a script to make a daily backup of the owncloud database
> and store it on my NAS device for backups. The script is scheduled via cron
> to be execute each night. On the backup NAS I have a folder structure for
> the dumps which keeps each dump for four weeks. Older dumps are
> automatically
> removed by the script.
>
> I can easily restore the content of the DB using phpMySQL which runs on the
> same host as owncloud.
>
> This is a prototype of my script:
>
> #!/bin/sh
>
> dbhost=mysql
> dbuser=backup
> dbpw=OhSoSecret
> backup=/media/backup/$dbhost/week1
> level=`date +%u`
>
> mount | grep /media/backup > /dev/null
>
> if [ $? -eq 0 ] ; then
> echo "Another backup is still in progress"
> exit 1
> fi
>
> mount -t nfs backup:/volume1/backup /media/backup
>
> if [ $? -ne 0 ] ; then
> echo "Unable to mount backup share"
> exit 2
> fi
>
> if [ ! -d /media/backup/$dbhost ] ; then
> mkdir /media/backup/$dbhost
> if [ $? -ne 0 ] ; then
> echo "Unable to create folder /media/backup/$dbhost"
> umount /media/backup
> exit 3
> fi
> fi
>
> if [ $level -eq 1 ] ; then
> for i in 4 3 2 1; do
> if [ -d /media/backup/$dbhost/week$i ] ; then
> j=$(($i+1))
> mv /media/backup/$dbhost/week$i `
> /media/backup/$dbhost/week$j
> fi
> done
> fi
>
> if [ ! -d $backup ] ; then
> mkdir $backup
> if [ $? -ne 0 ] ; then
> echo "Unable to create folder $backup"
> umount /media/backup
> exit 4
> fi
> fi
>
> /usr/local/bin/mysqldump --host=$dbhost `
> --user=$dbuser `
> --password=$dbpw `
> owncloud | `
> /usr/local/bin/bzip2 -9 > `
> $backup/$db.$level.sql.bz2
>
> if [ $? -ne 0 ] ; then
> echo "Dump of owncloud db failed"
> fi
>
> if [ -d /media/backup/$dbhost/week5 ] ; then
> rm -rf /media/backup/$dbhost/week5
> if [ $? -ne 0 ] ; then
> echo "Unable to remove folder /media/backup/$dbhost/week5"
> fi
> fi
>
> umount /media/backup
>
> if [ $? -ne 0 ] ; then
> echo "Unable to umount backup share"
> exit 5
> fi
>
> exit 0
>
>
>
>> I look forward to learning more about this! Thank you.
>>
>> Kyle
>
>
> I hope this helps you.
>
> Bruno
>
> _______________________________________________
> Owncloud mailing list
> Owncloud at kde.org
> https://mail.kde.org/mailman/listinfo/owncloud
More information about the Owncloud
mailing list