How do I backup and restore Asset Bank?
If you host your Asset Bank on one of your own servers then you should ensure it is backed up regularly by following the instructions below. (If your Asset Bank is hosted by us then you don't need to worry - we perform nightly backups).
There are two steps involved in backing up the Asset Bank application:
- Backup the database
- Backup the directory (or directories) that store the asset files.
Backing up the database
You should schedule a daily backup of the Asset Bank database preferably at a time when the system is quiet (e.g. at night). Note however that Asset Bank does not have to be stopped while the backup process is running. For your convenience a script is provided with Asset Bank which backs up a MySQL database running on a Windows server (details of this are given below). For SQL Server databases you will need to create a maintenance plan to backup the database to a file on a daily basis (http://msdn.microsoft.com/en-us/library/ms189647.aspx) and then backup the resulting file with the application and digital assets. Oracle backups are normally managed by your DBA, contact them to make sure that backups are happening.
Backup procedure for MySQL
The scripts included in the directory [tomcat]/webapps/asset-bank/WEB-INF/manager-config/backup perform a backup of the MySQL database used by Asset Bank. The backups are created in directories with names corresponding to the day of backup run. We recommend the following backup procedure:
1. Open the file backup.vbs (or backup.sh) in a text editor. The top part of the file contains settings that you can change according to your environment (directory paths and database access details). Comments within the file describe these settings.
2. On Windows Set BACKUP_FILES_INCLUDED = 1 if you want the script to copy the asset files into the same directory as the database dump file. Generally you don‘t need to do this - it is simplier to just backup the directories Asset Bank uses to store its files directly. Please note if you do set this option you will need to set FILE_STORE_DIR to point to the directory where the files are stored. The script does not allow for Asset Banks that use multiple file stores (‘storage devices‘) - if you are using more than one then make sure you back up each one manually as described below.
3. To run the script manually (for example, to test the script), run the batch file backup.bat within a command prompt. Output will be written to a file out.txt, and if the script works correctly you should see the backup files in the appropriate directory.
4. To schedule the data backup, use Windows Scheduled Tasks on Windows.
- Control Panel > Scheduled Tasks > Add Scheduled Task
- In the wizard, click Browse, find and select backup.bat
- Set frequency and time of task
- Enter account details of an account with appropriate permissions (eg administrator).
Remember to update the task properties if the password for the account used changes.
5. On Linux schedule a cronjob to be run daily (e.g. # Daily database backups
0 23 * * * cd /var/lib/tomcat/asset-bank/WEB-INF/manager-config/database; nice -n7 sh backup.sh)
Backing up the files
Your backup procedure should ensure that the database data and file data are backed up at the same time, ideally when the system is not in use. This will ensure that the backup data is synchronised and consistent. If files are being added or deleted during the backup, some manual updates may be needed on restored data to recover consistency.
You should backup the entire ‘asset-bank‘ webapp directory (and all its subdirectories), e.g. [tomcat]/webapps/asset-bank - this will speed up the restore process.
By default, Asset Bank uses one ‘files‘ directory to store the asset files, which is located within the asset-bank webapp (e.g. in [tomcat]/webapps/asset-bank/files). Therefore, if you have not changed the default, then the asset files will be backed up when the ‘asset-bank‘ webapp is backed up.
If you have configured your Asset Bank to use more than one directory to store its files, or you have changed the default directory to be outside the ‘asset-bank‘ webapp directory, you will need to backup each of these directories. You can see which directories Asset Bank uses to store its files by going to Admin->System->Storage Devices and examining each Storage Device.
Restoring data
File data
The file directory (or directories) should be restored to their original locations.
Database data
Restore your database from the database backup file. Please refer to instructions from your database provider for specific instructions for restoring from backup. As an example the method for restoring a MySQL database is given below.
The command below restores the backup database file ‘backup.sql‘ to the MySQL database ‘assetbank‘. The root user is being used with password ‘password‘.
- If an old version of the database already exists(in this example, 'assetbank') and you are sure you are happy to replace it, drop it with this command:
mysql -u root -ppassword -h localhost -e "DROP DATABASE assetbank;"
- Create an empty database:
mysql -u root -ppassword -h localhost -e "CREATE DATABASE assetbank;"
- Ensure that the Asset Bank database user has permissions on the new database:
mysql -u root -ppassword -h localhost -e "GRANT ALL ON assetbank.* TO 'application'@'localhost';"
- Load the schema and data from the backup file into the new database:
mysql -u root -ppassword -h localhost assetbank < backup.sql