2.0/Backing up and Restoring ProcessMaker
ProcessMaker holds vital information about your organization's users and their work; therefore, it is very important you establish and maintain a backup system to safeguard the data being stored in ProcessMaker. If periodic backups aren't being made, one lightning strike or an accidental deletion of key files on your system could bring your organization to a grinding halt. Backups can also be very useful for returning to a previous state after making experimental changes to your system or applying an upgrade patch to ProcessMaker.
It is recommended that your entire system be backed up in case the entire operating system needs to be restored. For the data stored in ProcessMaker, it is recommended to periodically backup your workspaces. Depending on how critical your data is and how often is is being updated, a daily backup or a weekly backup would be appropriate.
ProcessMaker version 2.0 offers the new "processmaker" command line utility to backup and restore Workspaces, which solves the limitations of the previous backup and restore utility offered by the "gulliver workspace-backup" command in ProcessMaker version 1.X. If still using ProcessMaker version 1.X, see this page.
Backing up Workspaces
The workspace backup utility creates a tar file which contains a dump of the three databases for each workspace and its associated files, which are stored in the INSTALL-DIRECTORY/shared/sites/WORKSPACE/ directory. Additional workspaces can be created in ProcessMaker, but most installations of ProcessMaker will have the default "workflow" workspace, which uses the wf_workflow, rb_workflow, and rp_workflow databases and stores its files in the shared/sites/workflow/ directory.
To backup a workspace, open a command line prompt in the server running ProcessMaker.
Hint: If unable to find the command line prompt, in Windows, go to Start > All Programs > Accessories > Command Prompt. If using a GNOME-based Linux/UNIX system, in the main menu, go to Accessories > Terminal.
Note for Linux/UNIX: If the shared directory has been set to 770 permissions for security reasons, then login as "root" or sudo when backing up a workspace. Another option is to add your user to the apache group (which is "apache" for Red Hat/CentOS/Fedora, "www-data" for Debian/Ubuntu, and "www" for SUSE/OpenSUSE), so that user can do backups:
useradd -G apache-group username
Navigate to the directory where ProcessMaker is installed. For example:
Windows XP/Server 2003:
cd "C:\Program Files\ProcessMaker-2_0_23\processmaker"
Windows Vista/7/Server 2008:
Then, issue the command to backup a workspace:
processmaker workspace-backup WORKSPACE [BACKUP-FILE]
WORKSPACE is the name of the workspace to backup. Remember that workspace names are case sensitive.
By default, the backup file will be created at INSTALL-DIRECTORY/shared/backups/WORKSPACE.tar, however the location of the backup file can be specified with the optional BACKUP-FILE parameter. This parameter can include forward slashes "/" to specify a path in Linux/UNIX or backward slashes "\" to specify a path in Windows. If the path or filename contains spaces, enclose it in double quotation marks. If using a relative path, then it will start from the location of the processmaker script. If no path is specified, then the file will be created in the shared/backups directory.
Note: If using Linux/UNIX, it is necessary to specify the directory where the processmaker script is located, so prepend "./" to specify the current directory:
./processmaker workspace-backup WORKSPACE [BACKUP-FILE]
Backup the default "workflow" workspace on a Linux/UNIX server to the location /opt/processmaker/shared/backups/workflow.tar:
./processmaker workspace-backup workflow
Backup the "sales" workspace on a Linux/UNIX server to the location "/home/amos/store/pm_sales.tar":
./processmaker workspace-backup sales /home/amos/store/pm_sales.tar
Backup the "Finance" workspace to the location /opt/store/Finance/FinanceBackup.tar, using a relative path:
./processmaker workspace-backup Finance ../store/FinanceBackup.tar
Backup the "sales" workspace on a Windows server to the location C:\Documents and Settings\Amos\sales backup.tar. Remember to enclose paths and filenames with spaces in double quotes:
processmaker workspace-backup sales "C:\Documents and Settings\Amos\sales backup.tar"
For help using the workspace-backup option, enter the command:
processmaker help workspace-backup
While executing a workspace backup, the output will indicate which tables are being backed up and print a summary of the backup at the end, similar to the following:
$ cd /opt/processmaker $ ./processmaker workspace-backup workflow Backing up to /opt/processmaker/shared/backups/workflow.tar Backing up database... Saving database wf_workflow LOCK TABLES [OK] Dump of table ADDITIONAL_TABLES 294 Bytes Saved Dump of table APPLICATION 43950 Bytes Saved Dump of table APP_CACHE_VIEW 24274 Bytes Saved Dump of table APP_DELAY 0 Bytes Saved Dump of table APP_DELEGATION 18370 Bytes Saved Dump of table APP_DOCUMENT 3324 Bytes Saved Dump of table APP_EVENT 0 Bytes Saved Dump of table APP_FOLDER 0 Bytes Saved Dump of table APP_HISTORY 3000 Bytes Saved Dump of table APP_MESSAGE 0 Bytes Saved Dump of table APP_OWNER 0 Bytes Saved Dump of table APP_THREAD 5115 Bytes Saved Dump of table CALENDAR_ASSIGNMENTS 0 Bytes Saved Dump of table CALENDAR_BUSINESS_HOURS 106 Bytes Saved Dump of table CALENDAR_DEFINITION 170 Bytes Saved Dump of table CALENDAR_HOLIDAYS 0 Bytes Saved Dump of table CASE_SCHEDULER 0 Bytes Saved Dump of table CASE_TRACKER 96 Bytes Saved Dump of table CASE_TRACKER_OBJECT 0 Bytes Saved Dump of table CONFIGURATION 6686 Bytes Saved Dump of table CONTENT 72907 Bytes Saved Dump of table DB_SOURCE 0 Bytes Saved Dump of table DEPARTMENT 0 Bytes Saved Dump of table DIM_TIME_COMPLETE 0 Bytes Saved Dump of table DIM_TIME_DELEGATE 0 Bytes Saved Dump of table DYNAFORM 4041 Bytes Saved Dump of table EVENT 1079 Bytes Saved Dump of table EXP_CATEGORY 181 Bytes Saved Dump of table EXP_ITEM 819 Bytes Saved Dump of table FIELDS 829 Bytes Saved Dump of table FIELD_CONDITION 0 Bytes Saved Dump of table GATEWAY 876 Bytes Saved Dump of table GROUPWF 290 Bytes Saved Dump of table GROUP_USER 530 Bytes Saved Dump of table HOLIDAY 0 Bytes Saved Dump of table INPUT_DOCUMENT 286 Bytes Saved Dump of table ISO_COUNTRY 15891 Bytes Saved Dump of table ISO_LOCATION 4453699 Bytes Saved Dump of table ISO_SUBDIVISION 66412 Bytes Saved Dump of table LANGUAGE 11202 Bytes Saved Dump of table LEXICO 0 Bytes Saved Dump of table LOGIN_LOG 10096 Bytes Saved Dump of table LOG_CASES_SCHEDULER 0 Bytes Saved Dump of table OBJECT_PERMISSION 0 Bytes Saved Dump of table OUTPUT_DOCUMENT 854 Bytes Saved Dump of table PROCESS 1640 Bytes Saved Dump of table PROCESS_CATEGORY 0 Bytes Saved Dump of table PROCESS_OWNER 0 Bytes Saved Dump of table PROCESS_USER 0 Bytes Saved Dump of table REPORT_TABLE 446 Bytes Saved Dump of table REPORT_VAR 2445 Bytes Saved Dump of table ROUTE 5381 Bytes Saved Dump of table SESSION 179 Bytes Saved Dump of table SHADOW_TABLE 7058 Bytes Saved Dump of table STAGE 0 Bytes Saved Dump of table STEP 3310 Bytes Saved Dump of table STEP_SUPERVISOR 0 Bytes Saved Dump of table STEP_TRIGGER 3447 Bytes Saved Dump of table SUB_APPLICATION 0 Bytes Saved Dump of table SUB_PROCESS 192 Bytes Saved Dump of table SWIMLANES_ELEMENTS 2269 Bytes Saved Dump of table TASK 7833 Bytes Saved Dump of table TASK_USER 848 Bytes Saved Dump of table TRANSLATION 799302 Bytes Saved Dump of table TRIGGERS 7245 Bytes Saved Dump of table USERS 1925 Bytes Saved Dump of table USERS_PROPERTIES 320 Bytes Saved UNLOCK TABLES [OK] Saving database rp_workflow LOCK TABLES [OK] Dump of table EXP_DETAILS 0 Bytes Saved Dump of table EXP_EXPENSES 515 Bytes Saved UNLOCK TABLES [OK] Saving database rb_workflow LOCK TABLES [OK] Dump of table AUTHENTICATION_SOURCE 0 Bytes Saved Dump of table PERMISSIONS 2969 Bytes Saved Dump of table ROLES 709 Bytes Saved Dump of table ROLES_PERMISSIONS 3277 Bytes Saved Dump of table SYSTEMS 260 Bytes Saved Dump of table USERS 1440 Bytes Saved Dump of table USERS_ROLES 642 Bytes Saved UNLOCK TABLES [OK] Copying database to backup... + /opt/processmaker/shared/upgrade/EB0oxI Copying files to backup... + /opt/processmaker/shared/sites/workflow ProcessMaker Version 2.0.23 System Ubuntu 10.04 LTS (Linux) PHP Version 5.2.10-2ubuntu6 Server Address 192.168.1.76 Client IP Address 192.168.0.168 Plugins charts openFlash pmosCommunity processTemplate Workspace Name workflow Workflow Database mysql://wf_workflow:4dsmjw378rgh@localhost:3306/wf_workflow RBAC Database mysql://rb_workflow:4dsmjw378rgh@localhost:3306/rb_workflow Report Database mysql://rp_workflow:4dsmjw378rgh@localhost:3306/rp_workflow MySql Version MySql (Version none)
Backing up Bigger Workspaces
Available version: From 2.5
Sometimes, the backup is too bigger to be handle in some OS configurations. To solve this issue a new parameter
- s was added to back up workspaces with files bigger than 2 GB in size, this parameter allows to compress the file into several ones:
-s[ <megabyte_max_files_size>] WORKSPACE [BACKUP-FILE]
- megabyte_max_files_size: parameter to specify the size, in parts, file will be compress, for instance if it is a file of 2 GB to backup, this parameter may be defined with
1024, it means the it wilb be compress in two parts of 1024 MB.
- s parameter is not used, the command above won't back up files more than 2 GB in size.
Note: This parameter can only be used under Linux Servers.
Backing up Multiple Workspaces
From version 2.0.23 on, it is possible to backup multiple workspace at the same time, with the command:
processmaker workspace-backup WORKSPACE1 [WORKSPACE2 WORKSPACE3...] BACKUP-FILE
Separate each workspace name with a space. The last parameter will be considered the name of the backup file.
For example to backup, the "workflow", "sales" and "Finance" workspaces to the file "pmBackup.tar":
./processmaker workspace-backup workflow sales Finance pmBackup.tar
Backups should be made periodically, so it is best to automate the backup process.
In Linux/UNIX, the backups can be scheduled as a cron job. For more information on the format of the crontab file, see Configuring crontab in Linux/UNIX.
For example, the following line could be added to the /etc/crontab file to automatically backup the "workflow" workspace every 12 hours and save it to a file at /opt/processmaker/backups/workflow.tar:
* */12 * * * root /opt/processmaker/processmaker workspace-backup workflow
Inserting Date/Time in Filenames
The problem is that the backup file will be overwritten every 12 hours, so it will not be possible to use the processmaker workspace-restore command to roll the workspace back to a state which is older than 12 hours. For example, if a database gets corrupted 3 days ago, the backup file will have already been overwritten, so it isn't possible to recover the old database. Therefore, it is recommended to use a time stamp in the backup file name, so multiple backup files can be maintained. However, old backup files also need to be periodically eliminated so that the backups don't eat up all the harddrive space on the server.
These cron jobs could be used to make a backup file every 12 hours and save it to a file at /root/backups/workflow_YYYY-MM-DD_HH-MM.tar, and automatically delete the old backup files which are more than 30 days old:
* */12 * * * root /opt/processmaker/processmaker workspace-backup workflow /root/backups/workflow_`date +%F_%H-%M`.tar * */23 * * * root tmpwatch 720 /root/backups
The current date and time is automatically inserted into the filename with the date command, such as "workflow_2011-03-21_12-01.tar". Make sure to use `` (backticks), so Linux/UNIX will execute the date command, rather than treating it like a quoted string.
The second command automatically deletes any files older than 30 days (30days x 24hours = 720hours) in the /root/backups/ directory every night at midnight, so old backup files will not occupy too much space. If on a Debian or Ubuntu server, use the tmpreaper command instead of tmpwatch.
Storing Backups Remotely
It is recommended to keep backup copies in a different server (in a different location), so that a harddrive failure or lightning strike in the ProcessMaker server won't also destroy the backup copies. The following script named "/usr/local/bin/pmbackup.sh" could be used to make a backup of the "workflow" workspace and store it in another location:
#!/bin/bash CURDATE=$(date +%F_%H-%M) /opt/processmaker/processmaker workspace-backup workflow /root/backups/workflow_$CURDATE.tar gzip /root/backups/workflow_$CURDATE.tar scp /root/backups/workflow_$CURDATE.tar.gz email@example.com:/root/backups/ rm /root/backups/workflow_$CURDATE.tar.gz
Make sure that the script file is executable:
chmod +x /usr/local/bin/pmbackup.sh
In order to be able to copy the backup files to the remote server at backups.example.com without having to enter a password for the root user, generate a public/private key with the command:
ssh-keygen -t rsa
Add the public key to the /root/.ssh/authorized_keys file in the backups.example.com server. For more information, see this article. Then, add the pmbackup.sh script as a cron job on the ProcessMaker server.
* */23 * * * root /usr/local/bin/pmbackup.sh
On Windows servers, workspaces can be periodically backed up as a Scheduled Task. Use the SCHTASKS command in DOS to create a Scheduled Task which periodically executes the processmaker workspace-backup command. For more information on using the SCHTASKS command, see Executing cron.php with the SCHTASKS command.
1. Backup the default "workflow" workspace every day at midnight and 1pm (during the lunch break) on a ProcessMaker server installed at C:\Users\Bob\AppData\Roaming\ProcessMaker-2_0_30\processmaker:
SCHTASKS /Create /U administrator /P p4s5w0rd /SC DAILY /ST 00:00,13:00 /TR ^ "C:\Users\Bob\AppData\Roaming\ProcessMaker-2_0_30\processmaker\processmaker workflow-backup workflow"
2. Backup the "sales" workspace to the file C:\Documents and Settings\Bob\Backups\sales workspace.tar every Sunday and Wednesday at midnight on a ProcessMaker server installed at C:\Program Files\ProcessMaker-2_0_30\processmaker:
SCHTASKS /Create /U administrator /P p4s5w0rd /SC WEEKLY /D SUN,WED ST/ 00:00 /TR ^ "'C:\Program Files\ProcessMaker-2_0_30\processmaker\processmaker' workflow-backup sales 'C:\Documents and Settings\Bob\Backups\sales workspace.tar'"
Notice how paths and file names which contain spaces are enclosed inside single quotation marks.
3. Backup the "sales" workspace to the file SalesBackup.tar on the 15th of every month at 11pm:
SCHTASKS /Create /U administrator /P p4s5w0rd /SC MONTHLY /D 15 /ST 23:00 /TR ^ "C:\Users\Bob\AppData\Roaming\ProcessMaker-2_0_30\processmaker\processmaker workflow-backup sales SalesBackup.tar"
Inserting Date/Time in Filenames
It is not possible to insert the current date and time in the backup filename using the system %date% and %time% variables, since SCHTASKS treats them as literal strings. Instead, create a .bat file to execute the processmaker workspace-backup command. For example, the file C:\Users\Bob\pmbackup.bat contains:
C:\Users\Bob\AppData\Roaming\ProcessMaker-2_0_30\processmaker\processmaker workflow-backup workflow workflow-%date%-%time%.tar
Then, use the SCHTASKS command to schedule the periodic execution of the C:\Users\Bob\pmbackup.bat file:
SCHTASKS /Create /U administrator /P p4s5w0rd /SC DAILY /ST 00:00,13:00 /TR "C:\Users\Bob\pmbackup.bat"
Storing Backups Remotely
To securely copy files from Windows, install PuTTY's pscp program in the ProcessMaker server. Then, create a .bat file to execute the processmaker workspace-backup command and use pscp to copy the backup file to a remote server.
For example, the file C:\Documents and Settings\Bob\pmbackup.bat contains the following code to copy the backup file to the /root/backups directory on a remote Linux/UNIX server with a domain name of "example.com":
"C:\Program Files\ProcessMaker-2_0_30\processmaker\processmaker" workflow-backup workflow "C:\Program Files\PuTTY\PSCP.EXE" -pw p4s5w0rd "C:\Program Files\ProcessMaker-2_0_30\processmaker\backups\workflow.tar" firstname.lastname@example.org:/root/backups/workflow-%date%-%time%.tar
Then, use the SCHTASKS command to schedule the periodic execution of the C:\Documents and Settings\Bob\pmbackup.bat file:
SCHTASKS /Create /U administrator /P p4s5w0rd /SC DAILY /ST 00:00 /TR "Documents and Settings\Bob\pmbackup.bat"
To copy the backup files to a remote Windows server, install an SSH server on the remote Windows server (with programs such as freeSSHd, CygWin or WinSSHD), so it can accept secure file transfers. Another option is using PuTTY's psftp command to transfer the files using the SFTP protocol.
To restore a workspace from a backup, use the command:
processmaker workspace-restore BACKUP-FILE [WORKSPACE]
If the backup file has an extension of ".tar" and it is located in the shared/backups directory, then it is not necessary to specify the path or the extension.
For example, to restore from the shared/backups/workflow.tar backup file in Linux/UNIX:
./processmaker workspace-restore workflow
If the backup file is not located in the shared/backups directory or it doesn't have an extension of ".tar", then specify the path. Remember to enclose it within double quotes if the file name or path contains spaces. For example, to restore a workspace from the "c:\Documents and Settings\Amos\sales backup.tar" file in Windows:
processmaker workspace-restore "c:\Documents and Settings\Amos\sales backup.tar"
By default the backup will be restored to the same workspace name and use the same databases names as the original. To overwrite an existing workspace, use the -o or --overwrite option. For example, to overwrite the existing "workflow" workspace:
./processmaker workspace-restore -o template_name workflow
To restore to a different workspace name, specify the optional WORKSPACE parameter. A new workspace will be created with 3 databases named "wf_WORKSPACE", "rb_WORKSPACE" and "rp_WORKSPACE". The workspace name should only use valid characters for MySQL databases, so it can not contain hyphens "-", spaces, periods, commas, semicolons or other special characters. To avoid problems, it is recommended to only use ASCII letters, numbers and underscores "_" for workspace names, since the workspace name should be easy to represent in a web address. Remember that workspace names are case sensitive when being entered in a URL in a web browser, but MySQL databases in Windows are not case sensitive, whereas MySQL databases in Linux/UNIX are case sensitive.
For example, to import the backup file at "shared/backups/workflow.tar" with the workspace name of "finance":
./processmaker workspace-restore -o workflow finance
To only show information about a backup file, use the -i option. For example, to show information about the workspace(s) in the sales.tar backup file:
./processmaker workspace-restore -i sales
To restore a workspace from a backup file which has multiple workspaces, use the -w or --workspace= option to specify which workspace should be restored. For example, to restore the "Finance" workspace from the file pmBackup.tar and overwrite the existing "accounting" workspace:
./processmaker workspace-restore -o --workspace=finance pmBackup finance
./processmaker workspace-restore -o pmBackup finance
For help using the processmaker workspace-restore command:
processmaker help workspace-restore
To restore workspaces with more than 2 GB in size run the following command:
./processmaker workspace-restore -m <workspace> <destinationFile.tar> <workspacedestination>
This command is available from version 2.5
- m parameter is not used, the command above won't restore workspaces with more than 2 GB in size. This parameter can only be used under Linux Servers.
Note for Linux/UNIX: All the workspace files from the backup will be created in the INSTALL-DIRECTORY/shared/sites/WORKSPACE/ directory, with the same file permissions and same file owner as the shared directory. If needing greater security, change those file permissions.
Importing Workspaces from ProcessMaker 1.X into 2.X
If a backup was made of a workspace in ProcessMaker 1.X with the gulliver workspace-backup command, then the best option is to import that workspace into the same version of ProcessMaker using the gulliver workspace-restore command. Then, upgrade that installation of ProcessMaker to version 2.X.
If ProcessMaker is already version 2.X, so it can't be upgraded, then it is still possible to import the old backup file using the the gulliver workspace-restore command. However, after restoring the workspace, the database tables and workspace files need to be upgraded to match version 2.X, by changing to the INSTALL-DIRECTORY and issuing the processmaker upgrade command:
cd INSTALL-DIRECTORY ./processmaker upgrade
Importing Workspaces into newer versions of 2.X
If importing a workspace which was created in an older version of ProcessMaker 2.X into a newer version of ProcessMaker 2.X, then use the processmaker workspace-restore command. Afterwards, update the database tables and workspace files to the new version, by changing to the INSTALL-DIRECTORY and issuing the processmaker upgrade command:
cd INSTALL-DIRECTORY ./processmaker upgrade