====Backup & Restore==== ===Backing up ownCloud=== When you backup your ownCloud server, there are four things that you need to copy: * Your config/ directory. * Your data/ directory. * Your ownCloud database. * Your custom theme files, if you have any 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 . ==Backing Up the config/ and data/ Directories== 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. ==Backup Database== 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 ===Restoring ownCloud=== 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): * Your config/ directory. * Your data/ directory. * Your ownCloud database. * 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 Setting Strong 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 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. ==Restore Database== **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