owncloud backup script for linux servers. Also compatible to nextcloud.
This script alllows to backup your owncloud (or nextcloud) installation with data and its SQL Database. You can run this
script
on your linux server where your cloud is installed. In my case this scripts saves me a lot of time: During the backup my
owncloud installation is unavailable for just 2 hours instead of days (I’m using encryption and I have a lot of small
files to download). Please read the Requirements before using
this script.
Some statistics: My owncloud folder (data + owncloud installation) has a size of 112 GB and contains 492733 files (
incl. encryption keys). The size of the backup is only 75.5 GB. My owncloud installation was in maintenance mode for
just 77 minutes. After that I downloaded the files with full speed.
An owncloud/nextcloud installation can contain a lot of small files, especially if you are using server-side encryption.
If you try to
make a remote backup via FTPS/SFTP your download-speed will be low because your FTP-Client tries to download those many,
small
files. It’s better to download bigger files, e.g. of size 1GB. Further more your owncloud is unavailable just for the
time the backup files are created, not for the time you need to download the files.
It’s just a shell script. It enables the maintenance mode, makes a backup of the SQL database, a backup of the data
directory and a backup of the owncloud installation directory. After it has finished the backup it disables the
maintenance mode automatically.
zip
and mysqldump
exist.
git clone https://github.com/julianpoemp/oc-backup.git
oc_backup_sample.cfg
and rename it to oc_backup.cfg
sh ./oc_backup.sh
. While it is running your owncloud is in maintenance mode.If you installed oc_backup manually you need to update manually. I recommend to clone this repository so you just have
to call git pull
to receive updates.
Assuming your data directory and your owncloud directory are in the same folder called “myowncloud.com”:
OCB_TYPE="owncloud"
OC_INSTALLATION_PATH=/path/to/myowncloud.com/owncloud
OC_DATA_PATH=/path/to/myowncloud.com/data
OC_DB_NAME=owncloud
OC_DB_USER=user
OC_DB_PASSWORD=password
BACKUP_PATH=/path/to/backup
CREATE_LOGFILE=true
-c | Absolute path to the config file for oc-backup. |
-h | Show help text. |
\1 Affiliate Link. If you buy a product I’ll get a small commission :)
In that case there are two options:
1) If you are not using server-side encryption you could try
to make a backup without SSH access.
2) If you are using server-side encryption you have a lot of small files for sure. In that way I recommend you to get
SSH access. If you don’t want to, you could try making a backup manually, but the download speed will be very very
slow and the backup will take a lot of more time.
As an alternative to a standard FTP-Client you could use
my webspace-backup application.
crontab -e
00 4 * * * <absolute path to oc_backup.sh &> /dev/null
Example:
# run it every day at 4 a.m.
00 4 * * * /home/julian/oc_backup.sh -c /home/julian/somefolder/oc_backup.cfg &> /dev/null