Overview
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 it is being updated, a daily backup or a weekly backup would be appropriate.
Backing Up Workspaces
The workspace backup utility creates a tar file that 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.
Note: If unable to find the command line prompt, in Windows go to Start > All Programs > Accessories > Command Prompt. In most Linux/UNIX systems, it can be found under Accessories > Terminal.
Note for Linux/UNIX: If the shared directory has been set to 770 permissions for security reasons, then log in 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 the user can do backups:
Navigate to the directory where ProcessMaker is installed. For example:
Linux/UNIX:
Windows XP/Server 2003:
Windows Vista/7/Server 2008:
Then, issue the command to back up a workspace:
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 file name 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:
Examples:
Backup the default "workflow" workspace on a Linux/UNIX server to the location /opt/processmaker/shared/backups/workflow.tar:
Backup the "sales" workspace on a Linux/UNIX server to the location "/home/amos/store/pm_sales.tar":
Backup the "Finance" workspace to the location /opt/store/Finance/FinanceBackup.tar, using a relative path:
Backup the "sales" workspace on a Windows server to the location C:\Documents and Settings\Amos\sales backup.tar. Remember to enclose paths and file names with spaces in double quotes:
For help using the workspace-backup option, enter the command:
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:
$ ./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.0 and later in Linux/UNIX.If the backup file is larger than 2 GB, use the -s option, to break the backup file into multiple compressed files:
Where:
MAX-FILE-SIZE
: Specify the maximum size in megabytes of the backup file(s). If larger, the backup will be broken into multiple files of the specified size. For example, if this option is set to 1024, then a 4 GB backup will produce four backup files which are 1 GB in size.
If the -s
parameter is not used, this command won't backup files larger than 2 GB in size.
Note: This parameter can NOT be used on Windows servers.
Backing Up Multiple Workspaces
From version 2.0.23 on, it is possible to back up multiple workspaces at the same time with the command:
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":
Automating Backups
Backups should be made periodically, so it is best to automate the backup process.
Linux/UNIX
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 can 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:
Inserting Date/Time in File Names
Since the backup file will be overwritten every 12 hours, it will not be possible to use the processmaker workspace-restore command to roll the workspace back to a state older than 12 hours. For example, if a database was 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 hard drive space on the server.
These cron jobs can 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, as well as automatically delete the old backup files more than 30 days old:
* */23 * * * root tmpwatch 720 /root/backups
The current date and time is automatically inserted into the file name 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 on a different server (in a different location), so that a hard drive failure or lightning strike won't also destroy the backup copies on the ProcessMaker server. The following script named "/usr/local/bin/pmbackup.sh" can be used to make a backup of the "workflow" workspace and store it in another location:
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 root@backups.example.com:/root/backups/
rm /root/backups/workflow_$CURDATE.tar.gz
Make sure that the script file is executable:
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:
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.
Windows
On Windows servers, workspaces can be periodically backed up as a scheduled task. Use the SCHTASKS command in DOS to create a scheduled task that periodically executes the processmaker workspace-backup command. For more information on using the SCHTASKS command, see Executing cron.php with the SCHTASKS command.
Examples:
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:
"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:
"'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 that 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:
"C:\Users\Bob\AppData\Roaming\ProcessMaker-2_0_30\processmaker\processmaker workflow-backup sales SalesBackup.tar"
Inserting Date/Time in File Names
It is not possible to insert the current date and time into the backup fil ename 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:
Then, use the SCHTASKS
command to schedule the periodic execution of the C:\Users\Bob\pmbackup.bat file:
Storing Backups Remotely
To securely copy files from Windows, install PuTTY's pscp program on 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\PuTTY\PSCP.EXE" -pw p4s5w0rd "C:\Program Files\ProcessMaker-2_0_30\processmaker\backups\workflow.tar" root@example.com:/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:
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.
Restoring Workspaces
Note: If moving a workspace from a Windows server to a Linux/UNIX server, first see Migrating from Windows to Linux/UNIX.
To restore a workspace from a backup use the command:
If the backup file has a .tar extension and it is located in the shared/backups directory, then it is not necessary to specify the path or the extension.
Note: In version 2.5.2 and later, the response time of the processmaker workspace-restore
command has been improved, reducing considerably the time spent in restoring workspaces.
For example, to restore from the shared/backups/workflow.tar backup file in Linux/UNIX:
If the backup file is not located in the shared/backups directory or it doesn't have an extension .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 database names as the original. To overwrite an existing workspace, use the -o or --overwrite option. For example, to overwrite the existing "workflow" workspace:
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":
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:
To restore a workspace from a backup file that 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:
or:
For help using the processmaker workspace-restore command:
To restore workspaces with more than 2 GB in size run the following command:
The -m
parameter is available in version 2.5.0 and later in Linux/UNIX servers.
Note: If the -m parameter is not used, the above command won't restore workspaces larger than 2 GB in size. This parameter can only be used under Linux/UNIX 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. For 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 directory where ProcessMaker is installed (such as /opt/processmaker/) and issuing the processmaker upgrade
command:
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:
Manual Backup and Restore
Automating Backups
Backups should be made periodically, so it is best to automate the backup process.
Linux/UNIX:
In Linux/UNIX the backups can be scheduled as a cron
job. For example, to automatically backup ProcessMaker every 12 hours, the following lines could be added to the /etc/crontab file:
* */12 * * * root tar -czf /root/backups/pm_shared_`date +%F_%H-%M`.tar.gz
* */23 * * * root tmpwatch 720 /root/backups
The first command backups all the MySQL databases and compresses them with gzip before saving them to a file named pm_db_DATE_TIME.sql.gz. The current date and time is automatically inserted into the file name with the date command, such as pm_db_2011-03-21_12-01.sql.gz Make sure to use `` (backticks), so Linux/UNIX will execute the date command, rather than treating it like a quoted string.
The second command backups up the ProcessMaker shared directory to file with the current date and time in the file name, such as pm_shared_2011-03-21_12-01.tar.gz
Finally, every night at midnight, the third command automatically deletes any files older than 30 days (30days x 24hours = 720hours) in the /root/backups/ directory, so old backup files will not occupy too much space. If on a Debian or Ubuntu server, use the tmpreaper command instead of tmpwatch.
Windows:
The open source 7-Zip compression program has a command line version named 7za, which can be run as a Windows Scheduled Task to make backups of the shared directory. Create the new directory c:\Program Files\7za. Then [Downloaded 7az] and decompress its files in that new directory, so it can be used.
Then, go to Start > All Programs > Accessories > System Tools > Task Scheduler. In the "Task Scheduler" dialog box, click on Create Task. In the "Create Task" dialog box that appears, go to the General tab and enter a Name and Description.
Then go to the Triggers tab and click on the New button. For the Begin the Task: dropdown box, select "On a schedule". Under Settings select the Daily option. For Start, enter the date and hour when the backups should start and enter a number for how many days it should recur, then click on OK.
Back in the "Create Task" dialog box, go to the Actions tab and click on the New button. For the Action dropdown box, select "Start a program". In the Program/Script box, enter:
In the Add Arguments (0ptional) box, enter:
Then, click on the "OK" button.
Next create a second action to backup the MySQL databases. Back in the "Create Task" dialog box, go to the Actions tab and click on the New button. For the Action dropdown box, select "Start a program". In the Program/Script box, enter:
In the Add Arguments (0ptional) box, enter:
Then, click on the OK button twice to finish defining the Windows Scheduled Task.
Restoring ProcessMaker
It is not recommended to use data from one version of ProcessMaker with a different version of ProcessMaker. Reinstall the same version of ProcessMaker, which you were using previously.
If you want to use upgrade ProcessMaker to a newer version, first install the old version of ProcessMaker and then restore the data from your workspaces in the old version. Then, upgrade ProcessMaker to the newer version.
To restore the files in ProcessMaker's shared directory, simply delete the existing files and then decompress the backup file in its place.
Linux/UNIX:
In Linux/UNIX, the files can be restored from the command line:
tar -xzf /root/backups/pm_shared_2011-03-21_12-01.tar.gz
Then, decompress the gzipped database backup file and use it restore the MySQL databases:
mysql -u root -p > /root/backups/pm_db_2011-03-21_12-01.sql
If restoring to a different installation of MySQL it is necessary to recreate the 3 MySQL users for the 3 databases for each workspace and give them permissions to access their databases. If a backup was made of the mysql database, this can easily be done:
However, this will overwrite the existing configuration and users of the MySQL installation. If this is not desired, then it is probably best to manually create the users, with their same passwords and permissions, which can be found in the file <INSTALL-DIRECTORY>/shared/sites/<WORKSPACE>/db.php
Windows:
Delete the existing contents of the processmaker\shared\ directory. Then use 7-zip or WinRAR to decompress the backuped archive into its place.
To restore the MySQL databases, navigate to the mysql\bin directory and import the .sql backup file:
mysql -u root -p < "c:\Users\USERNAME\backups\pm_db.sql"