How to back up your ResourceSpace installation
It is vital to ensure all parts of ResourceSpace containing your resource files and metadata are backed up on a regular basis.
For our Cloud Hosted systems, be assured that extensive backup processes are in place and monitored regularly. This guide is for On-Premise or unsupported users.
The ideal scenario - server or VM image
The perfect scenario is to backup the entire server (or virtual machine) that is hosting ResourceSpace and all your resource files. This means recovery time is minimal as there's nothing to reconfigure. This involves taking a complete image of the system on a regular basis, and your organisation may have existing backup systems capable of this.
Backup of files and metadata only
If a full system backup is not possible, the following steps can be taken to ensure ResourceSpace is backed up. These should be incorporated into a scheduled script as appropriate.
- Use the mysqldump utility to dump the ResourceSpace MySQL database to an SQL text file. The database (backup) file will be formatted either as a MySQL Dump or MySQL Shell.
- Example command:
# Using MySQL Shell mysqlsh -h localhost --js --execute “util.dumpSchemas(['resourcespace'], '/path/to/backupFile', {threads: 32, bytesPerChunk: '100M'})" # Using MySQL Dump mysqldump -u root resourcespace > resourcespace.sql
- NOTE: Replace "resourcespace" with the $mysql_db value inside your config.php file. If you don't have access to the root MySQL user then use the credentials in the $mysql_username and $mysql_password config values instead.
- Take a backup copy of the complete ResourceSpace installation folder.
- On a Linux server the location may be /var/www/resourcespace
- On a Windows server the location may be C:\inetpub\wwwroot\resourcespace
- NOTE: The filestore folder is typically the largest component of the installation folder (containing all the resources in your system) you may wish to back up this folder separately.
- If the filestore folder is configured to be external to the ResourceSpace installation folder, ensure this is backed up too (otherwise you may be simply backing up a shortcut to the filestore folder).
Scheduled backups
The process above should ideally be run automatically with a recurring process on the server. On a Linux server this can be done with a cron job and on Windows the Task Scheduler program can be used.
Example Linux automated backup
Create a shell script containing the commands to back up the database and web root folder along with a timestamp with the following example contents:
Using MySQL Shell:
#!/bin/bash dumplocation="/server/backup/folder/rs-db-backup-`/bin/date +%Y%m%d`" if [ -d $dumplocation ]; then # If the backup directory exists purge old backup files rm -r $dumplocation/* else mkdir -p $dumplocation fi mysqlsh -h localhost --js --execute "util.dumpSchemas(['DB_Name'], '${dumplocation}', {threads: 32, bytesPerChunk: '100M'})" cp -b /var/www/resourcespace /server/backup/folder/rs-webroot-backup-'date +%Y%m%d'
Replace the DB_Name with the name of your ResourceSpace database leaving the quotation marks around the database name.
Using MySQL Dump:
#!/bin/bash mysqldump -uDBUSERNAME -pDBPASSWORD dbname > /server/backup/folder/rs-db-backup-'date +%Y%m%d'.sql cp -b /var/www/resourcespace /server/backup/folder/rs-webroot-backup-'date +%Y%m%d'
Replace DBUSERNAME, DBPASSWORD and dbname with the config options $mysql_username, $mysql_password and $mysql_db found in include/config.php
Make the script executable by adding the permission to the file:
chmod +x /path/to/script/backup_script.sh
Open the crontab editor:
crontab -e
Add the line below to run the backup script every day at 1am:
0 1 * * * /path/to/script/backup_script.sh
The 3-2-1 backup strategy
It's advisable to follow the 3-2-1 rule for backup copies.
- Keep at least 3 copies of your data - your live copy and two further backup copies.
- Store the copies on at least 2 different media devices.
- Ensure that at least 1 of your copies is offsite and rotate your offsite backups regularly.