| 1 | = Backup and restore a standard Debian-based Cinnamon repository |
| 2 | == Backup |
| 3 | * Switch to superuser context, using the {{{su}}} command. |
| 4 | * Create a file {{{/opt/cinnamon/cinnamon-system/backup.sh}}} with the following content: |
| 5 | {{{ |
| 6 | killall -SIGTERM supervise |
| 7 | kill $(ps aux | grep mono | awk '{print $2}') |
| 8 | service tomcat stop |
| 9 | |
| 10 | # Dump DB into cinnamon-data folder |
| 11 | export PGPASSWORD=<postgres_password> |
| 12 | pg_dump -U postgres -h localhost -w content > /opt/cinnamon/cinnamon-data/content.sql |
| 13 | export PGPASSWORD= |
| 14 | |
| 15 | # Delete empty folders in content store and archive data files in file system: |
| 16 | find /opt/cinnamon/cinnamon-data/content -empty -type d -delete |
| 17 | |
| 18 | # rsync over ssh |
| 19 | # this is available by many hosting providers and suits the backup needs of a Cinnamon repository very well |
| 20 | rsync -av --delete --rsh="/usr/bin/sshpass -p <password> ssh -p23" /opt/cinnamon/cinnamon-data/ <storage_url> |
| 21 | |
| 22 | service tomcat start |
| 23 | |
| 24 | sleep 60 |
| 25 | supervise /opt/cae/bin & |
| 26 | }}} |
| 27 | |
| 28 | * Set the permissions on the file to EXECUTE for root. |
| 29 | |
| 30 | > **IMPORTANT:** A password for the {{{postgres}}} user must be specified to enable pg_dump. |
| 31 | * Create a cron job running {{{backup.sh}}} at a suitable time. |
| 32 | * If the hosting provider offers such functionality, configure daily snapshots of the backup target at a time when all backups have been finished. |
| 33 | |
| 34 | == Restore |
| 35 | * Delete old DB and create a new one |
| 36 | {{{ |
| 37 | service tomcat stop |
| 38 | sudo -u postgres psql |
| 39 | drop database content; |
| 40 | \q |
| 41 | sudo -u postgres psql template1 |
| 42 | create database content with owner=cinnamon; |
| 43 | \q |
| 44 | sudo -u postgres psql content < /home/install/content.sql |
| 45 | }}} |
| 46 | |
| 47 | * Restore the content |
| 48 | Depending on where the content is available, restore it to the original content path ({{{/opt/cinnamon/cinnamon-data/content}}}). |
| 49 | > **NOTE:** In the configuration shown in the backup documentation, restore is most easily done by a reverse {{{rsync}}} command. |
| 50 | |
| 51 | > **NOTE:** Make sure that the account owning tomcat has read and write permission on the content. |
| 52 | |
| 53 | === Recreate the index |
| 54 | > **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. |
| 55 | {{{ |
| 56 | sudo -u postgres psql content |
| 57 | insert into index_jobs select id,false,'cinnamon.ObjectSystemData',id from objects; |
| 58 | insert into index_jobs select id,false,'cinnamon.Folder',id from folders; |
| 59 | }}} |