Simple Groupware Administration: Backup / Restore
System backup
Simple Groupware stores its data on the hard disk and the database. There are a lot of backup and restore techniques but I think this one should go with most of the cases.
Create a backup of the MySQL database:
<open a terminal>
mysqldump --add-drop-table --flush-logs --lock-tables --complete-insert --default-character-set=utf8 -r <output-file> -h <server> -u <username> -p <database>
Example:
mysqldump --add-drop-table --flush-logs --lock-tables --complete-insert --default-character-set=utf8 -r /backup/sgs.sql -h localhost -u root -p sgs_0_2
Create a backup of the PostgreSQL database:
<open a terminal>
pg_dump --clean --inserts --column-inserts -f <output-file> -h <server> -U <username> -W <database>
Example:
pg_dump --clean --inserts --column-inserts -f /backup/sgs.sql -h localhost -U postgres -W sgs_0_2
Create a backup of the Oracle database:
<open a terminal>
exp <username>@<database> file=<output-file> log=<log-file>
Example:
exp sgs_user@XE file=/backup/sgs.dmp log=/backup/sgs_backup.log
This creates a backup file containing all data needed to restore the database contents. Mysqldump is a database backup utility bundled with MySQL. Pg_dump is a database backup utility bundled with PostgreSQL. Exp is a database backup utility bundled with Oracle database.
Note: After creating the database backup, make sure that the output file is not empty.
Create a backup of the files stored on the hard disk:
<open a terminal>
tar --create --verify -f <output-file> --exclude 'simple_cache/*/*'
-C <path-to-sgs> ./
Example:
tar --create --verify -f /backup/sgs.tar --exclude simple_cache/*/* -C /var/www/localhost/sgs ./
Tar is an archiving utility. The windows version can be downloaded from here.
Note: After creating the hard disk backup, make sure that the output file is not empty.
System restore
After having done several backups it is very important to know how to restore them. Here is my favorite method:
Restore the MySQL database using the sql dump:
<open a terminal>
mysql --default-character-set=utf8 -p -u <username> -h <server> -D <database> < <input-file>
Example:
mysql --default-character-set=utf8 -p -u root -h localhost -D sgs_0_2 < /backup/sgs.sql
Restore the PostgreSQL database using the sql dump:
<open a terminal>
psql -q -W -U <username> -h <server> -d <database> -f <input-file>
Example:
psql -q -W -U postgres -h localhost -d sgs_0_2 -f /backup/sgs.sql
Restore the Oracle database using the dump:
<open a terminal>
imp <username-new>@<database> file=<input-file> log=<log-file-new> fromuser=<username-old> touser=<username-new>
Example:
imp sgs_user_new@XE file=/backup/sgs.dmp log=/backup/sgs_restore.log fromuser=sgs_user touser=sgs_user_new
This restores the database from the contents of the backup file. Mysql is a database restore utility bundled with MySQL. Psql is a database restore utility bundled with PostgreSQL. Imp is a database restore utility bundled with Oracle database.
Note: If you restore your backup to a different database, make sure to change the Simple Groupware config file (located at simple_store/config_<version>.php).
Restore the files using the tar file:
<open a terminal>
cd <path-to-sgs>
tar --extract --verbose -f <input-file>
Example:
cd /var/www/localhost/sgs
tar -k --extract --verbose -f /backup/sgs.tar
Note: This will not overwrite anything. Make sure that the target directory and the target database are empty.
Deleted datasets
All deleted datasets and all deleted folders are moved to /Workspace/System/Trash. From there you can delete them forever or restore them using cut/copy/paste.
Note: Lookups to the deleted item will be still active for the super administrator since he has access to the trash folder. E.g. when you delete a user, the select boxes will still show the username for the super administrator.
Note: The trash only includes datasets deleted in the database. For example, deleted mails in an IMAP folder won't appear in the trash folder.
Deleted files
All deleted files are moved to the folder "<sgs-dir>/simple_store/trash". Within Simple Groupware, you can access these files in "Workspace/System/Trash/files/trash".
Note: The trash folder only includes files deleted from datasets. For example, deleted files in a CIFS folder or a folder in the local file system won't appear in the trash.