Backing up ownCloud

27. July 2016 ownCloud 4,883

I’ve been mingling with ownCloud for about a year now.  We copy the ownCloud data over to an external USB Drive mounted on the system before we run any backups or updates on the system.  I have 2 folders on my USB drive, note them in the commands below.  Also my folder locations may be different than your setup.  You also need to know your mySQL root password to complete the mySQL dump.

My current system is as follows

Ubuntu 14.04 Server
ownCloud 9.0.1
mySQL database
Mounted 4TB external USB Drive

To backup an ownCloud installation there are three main things you need to retain:

  1. The config folder
  2. The data folder
  3. The database

Backup Folders

Put ownCloud into Maintenance mode:

Turn Maintenance mode on
cd /var/www/owncloud
sudo -u www-data php occ maintenance:mode –on
Simply copy your config and data folder (or even your whole ownCloud install and data folder) to a place outside of your ownCloud environment.
You could use this command:
sudo rsync -Aax owncloud/ /media/usb/ownCloud_Backups/owncloud-dirbkp_`date +”%Y%m%d”`/
Backup Database
MySQL is the recommended database engine. To backup MySQL:
sudo mysqldump –lock-tables  -u root -p owncloud > /media/usb/ownCloud_mySQL_Dumps/owncloud-sqlbkp_`date +”%Y%m%d”`.bak
As you run the backup, there is no response from CLI, so it may take awhile to complete.  Ours takes approx 4hrs @ 300gb of data.
When your backup is complete.
Turn Maintenance mode off
cd /var/www/owncloud
sudo -u www-data php occ maintenance:mode –off

Leave a Reply