= Backup and restore a standard Debian-based Cinnamon repository == Backup * Switch to superuser context, using the {{{su}}} command. * Create a file {{{/opt/cinnamon/cinnamon-system/backup.sh}}} with the following content: {{{ killall -SIGTERM supervise kill $(ps aux | grep mono | awk '{print $2}') service tomcat stop # Dump DB into cinnamon-data folder export PGPASSWORD= pg_dump -U postgres -h localhost -w content > /opt/cinnamon/cinnamon-data/content.sql export PGPASSWORD= # Delete empty folders in content store and archive data files in file system: find /opt/cinnamon/cinnamon-data/content -empty -type d -delete # rsync over ssh # this is available by many hosting providers and suits the backup needs of a Cinnamon repository very well # the ssh key of the target server must be confirmed rsync -av --delete --rsh="/usr/bin/sshpass -p ssh -p23" /opt/cinnamon/cinnamon-data/ service tomcat start sleep 60 supervise /opt/cae/bin & }}} * Set the permissions on the file to EXECUTE for root. > **IMPORTANT:** A password for the {{{postgres}}} user must be specified to enable pg_dump. * Create a cron job running {{{backup.sh}}} at a suitable time. * If the hosting provider offers such functionality, configure daily snapshots of the backup target at a time when all backups have been finished. == Restore * Delete old DB and create a new one {{{ service tomcat stop sudo -u postgres psql drop database content; \q sudo -u postgres psql template1 create database content with owner=cinnamon; \q sudo -u postgres psql content < /home/install/content.sql }}} * Restore the content {{{ rsync -avW /path/to/backup/cinnamon-data /opt/cinnamon }}} updates the {{{cinnamon-data}}} folder inside {{{/opt/cinnamon}}}. Depending on where the content is available, restore it to the original content path ({{{/opt/cinnamon/cinnamon-data/content}}}). > **NOTE:** In the configuration shown in the backup documentation, restore is most easily done by a reverse {{{rsync}}} command. > **NOTE:** Make sure that the account owning tomcat has read and write permission on the content. === Recreate the index > **NOTE:** If the system to restore to has no index for the restored repository yet, no further action has to be taken. In case of a restore over an existing repository, existing index files should be deleted before restore. {{{ sudo -u postgres psql content insert into index_jobs select id,false,'cinnamon.ObjectSystemData',id from objects; insert into index_jobs select id,false,'cinnamon.Folder',id from folders; }}}