When you backup your ownCloud server, there are four things that you need to copy:
When you install your ownCloud server from our Open Build Service) packages (or from distro packages, which we do not recommend) do not backup your ownCloud server files, which are the other files in your owncloud/ directory such as core/, 3rdparty/, apps/, assets/, lib/, and all the rest of the ownCloud files. If you restore these files from backup they may not be in sync with the current package versions, and will fail the code integrity check. This may also cause other errors, such as white pages.
When you install ownCloud from the source tarballs this will not be an issue, and you can safely backup your entire ownCloud installation, with the exception of your ownCloud database. Databases cannot be copied, but you must use the database tools to make a correct database dump.
To restore your ownCloud installation from backup, see Restoring ownCloud.
Simply copy your config/ and data/ folder to a place outside of your ownCloud environment. This example uses rsync to copy the two directories to /backupdir:
rsync -Aax config data /oc-backupdir/
There are many ways to backup normal files, and you may use whatever method you are accustomed to.
You can’t just copy a database, but must use the database tools to make a correct database dump.
MySQL or MariaDB, which is a drop-in MySQL replacement, is the recommended database engine. To backup MySQL/MariaDB:
mysqldump --lock-tables -h [server] -u [username] -p[password] [db_name] > owncloud-dbbackup_`date +"%Y%m%d"`.bak
sqlite3 data/owncloud.db .dump > owncloud-dbbackup_`date +"%Y%m%d"`.bak
PGPASSWORD="password" pg_dump [db_name] -h [server] -U [username] -f owncloud-dbbackup_`date +"%Y%m%d"`.bak
When you install ownCloud from packages, follow these steps to restore your ownCloud installation. Start with a fresh ownCloud package installation in a new, empty directory. Then restore these items from your backup (see Backing up ownCloud):
When you install ownCloud from the source tarballs you may safely restore your entire ownCloud installation from backup, with the exception of your ownCloud database. Databases cannot be copied, but you must use the database tools to make a correct restoration.
When you have completed your restoration, see Setting Strong Permissions.
Simply copy your configuration and data folder to your ownCloud environment. You could use this command, which restores the backup example in Backing up ownCloud:
rsync -Aax config data /var/www/owncloud/
There are many ways to restore normal files from backups, and you may use whatever method you are accustomed to.
This guide assumes that your previous backup is called “owncloud-dbbackup.bak”
MySQL is the recommended database engine. To restore MySQL:
mysql -h [server] -u [username] -p[password] [db_name] < owncloud-dbbackup.bak
rm data/owncloud.db sqlite3 data/owncloud.db < owncloud-dbbackup.bak
PGPASSWORD="password" pg_restore -c -d owncloud -h [server] -U [username] owncloud-dbbackup.bak