Backing up OpenCms
m |
|||
Line 27: | Line 27: | ||
− | The mysql configuration is called my.cnf. On Linux/Unix system, it resides under /etc/my.cnf. In this file there is a parameter called max_allowed_packet. If, for example, you want to accept | + | The mysql configuration is called my.cnf. On Linux/Unix system, it resides under /etc/my.cnf. In this file there is a parameter called max_allowed_packet. If, for example, you want to accept packets of up to 128 Megabytes in size, then you have to write |
max_allowed_packet=128M | max_allowed_packet=128M | ||
Revision as of 19:15, 5 November 2006
For a complete backup of an OpenCms installation you will need to backup:
- Configuration files
- The the servlet container
- The OpenCms database
Configuring OpenCms properly for production use can be a tricky and time consuming. Make sure you adequately document the process particular to your hosting environment and make backups of any relevant configuration files (eg the Apache mod_proxy config, the Tomcat server.xml, etc).
Backing up the servlet container is a straight forward file system backup.
Backing up the database is more complex. This procedure is specific to each database product and version number.
Contents |
OpenCms 6.x + MySQL 4.x on Linux
Option 1: mysqldump
The recommended way of backing up a MySQL database is to use the mysqldump command. This produces a SQL output which can then be restored using the mysql client.
The following command creates a compressed database backup, with a unique name:
mysqldump -v --flush-logs -u USERNAME --password=PASSWORD DATABASE_NAME | bzip2 >db_`date +%Y-%0m-%0d_%0H#%0M#%0S`.sql.bz2
USERNAME, PASSWORD and DATABASE_NAME have to be replaced with the name of your database user, that user's password and the name of your database.
Such a backup can later be restored by using the command
cat BACKUP-FILE.sql.bz2 | bunzip2 | mysql -u USERNAME --password=PASSWORD DATABASE_NAME
- Important Notice: for the restore to work, mysql has to accept very large database packets. Otherwise a 'max_packet_length exceeded error' is reported during the restore operation. If you allow large database packets, the memory of your server machine should not be too limited. If you cannot set your mysql to accept large packets, then you should not use this way of backing up your database.
The mysql configuration is called my.cnf. On Linux/Unix system, it resides under /etc/my.cnf. In this file there is a parameter called max_allowed_packet. If, for example, you want to accept packets of up to 128 Megabytes in size, then you have to write
max_allowed_packet=128M
Option 2: mysqlhotcopy
You can also use the mysqlhotcopy script which makes a safe copy of the underlying MySQL data files.
mysqlhotcopy --user=root opencms /var/tmp
To restore the backup simply place the directory which is created in the example above into the /var/lib/mysql directory. Make sure the correct file ownership and permissions are applied.
See http://dev.mysql.com/doc/refman/4.1/en/backup.html
Backing up using Database Export
It is also possible to backup an OpenCms site using the Administration -> Database Management -> Export Database tool. However there is a memory leak bug in OpenCms 6.0 in the import part of the process which can limit the size of the site which can be re-imported this way. (Is this fixed in 6.2.x?)