I am running ownCloud on my Synology NAS for some months now and I am pretty happy how reliable it works. But if in some case my RAID would fail I’d loose all my private data. A periodic backup needed to be set up that backs up all my data in addition to the ownCloud configuration and database.
A bash script! What else? It somehow built up from a simple copy to a full fledged backup-split-dump-log bash script that I’d like to share with you. The full script is at the bottom of this page. I’d now like to talk about the parameters you should now to use this script on your installation.
What it does
The script simply backs up all you ownCloud data and configuration so that you could make a fresh install in case of a total failure.
- Makes a database dump and copies it to the backup destination
- Archives, splits and copies the ownCloud data in 1GB files to the backup destination
- Copies the ownCloud configuration dir to the backup destination
This script should work with every installation of ownCloud using a MySQL database. I am running it on my Synology now but it was running on an Ubuntu Server for a year now successfully. Additionally you need a MySQL user that has SELECT and LOCK TABLES permissions on the owncloud database.
All user dependant parameters are located on the top of the script. They are:
[table id=3 /]
I am running the script through Task Scheduler once a week.
- Control Panel -> Task Scheduler
- Create -> Scheduled Task -> User-defined Script
- Task: ocbackup User: root This is very important
- Task Settings User-defined Script: Location of the ocbackup.sh file
Also available here: https://gist.github.com/noah95/9cd484c894ae629963c00a1ef973e8f9