Restoring ownCloud

Introduction

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 backup):

  1. Your config/ directory.

  2. Your data/ directory.

  3. Your ownCloud database.

  4. Your custom theme files, if you have any. (See Theming 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 Set Strong Directory Permissions.

Restore Directories

Simply copy your configuration and data folder to your ownCloud environment. You could use this command, which restores the backup example in backup:

sudo 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.

Restore Database

This guide assumes that your previous backup is called owncloud-dbbackup.bak.

MySQL

MySQL is the recommended database engine. To restore MySQL:

sudo -u www-data php occ maintenance:mode --on
sudo mysql -h [server] -u [username] -p[password] [db_name] < owncloud-dbbackup.bak
sudo -u www-data php occ maintenance:data-fingerprint
sudo -u www-data php occ maintenance:mode --off

SQLite

sudo rm data/owncloud.db
sudo sqlite3 data/owncloud.db < owncloud-dbbackup.bak

PostgreSQL

PGPASSWORD="password" pg_restore -c -d owncloud -h [server] -U [username] owncloud-dbbackup.bak