System Backups

As with any application, it is important to ensure that backups are performed regularly. PaperCut NG includes a built-in database export that saves the state of the database to a file. This functionality is designed to complement (not replace) a good system-wide backup process. The export is stored in the industry standard XML format and compressed using the standard ZIP format to reduce disk-space on the server and your backup medium. The use of these open standards ensures that your data is always available and accessible.

PaperCut NG makes the process of managing export backups simple by automatically performing a weekly export. Export backup files are placed in the following directory:

[app-path]\server\data\backups

The weekly exports are performed at 20 minutes past midnight on Sunday morning (or as otherwise defined by the schedule.weekly config key. Please see the section called “Using the Config Editor” to find out how to change config keys.)

Tip

In accordance with backup best practice, the above directory should be regularly backed-up to offline media (e.g. tape, CD or remote server). This will allow the data to be restored in the case the server hard-drive is corrupted. An example backup script called copy-backups-to-remote-server.bat found at [app-path]/server/examples/scripting/batch/ may help administrators automate the process of maintaining an off-disk copy.

On larger networks, it may be desirable to perform export backups more frequently than the in-built once a week period. The server-command tool may be used to execute the export task at other times. Simply write a script (e.g. batch file) to execute server-command perform-online-backup. Schedule the script to run at the desired intervals. More information on server-command is available in the section called “Server Commands (server-command)”.

Performing an Online Backup

In addition to the automated weekly exports, it is also possible to manually initiate a database export. This might be useful to back up the system database before performing an upgrade. To perform a manual export:

  1. Navigate to the OptionsBackups page.

  2. Press the Export Now button.

  3. A window will open showing the export progress and the location where the export file is saved.

Restoring an Export Backup

There are a number of situations when it might be necessary to restore a database, including:

To restore from an export file:

  1. Locate a previous export file.

  2. Shutdown the application server (See the section called “Stopping and Starting the Application Server”). The database cannot be in-use when performing the restore, so the application server needs to be stopped first.

  3. Open a command prompt. On Windows 7 and Server 2008 systems, this may need to be specifically elevated to run with administrator privileges, even if you are already logged in with an administrator account. Change to the server binaries directory. On a Windows system the directory location is [app-path]\server\bin\win\.

  4. Re-initialize the database back to an empty state by typing the following:

    db-tools init-db -f 
                            

  5. Run the import process by executing the following:

    db-tools import-db -f "C:\path\to\backup\backup-file-name.zip"
                            

    (Or, ./db-tools on some systems. See the section called “Database Tool (db-tools)” for more information on using db-tools) NOTE: On Mac/Linux ensure proper permissions for access to the file, e.g.

    chown papercut:admin \path\to\backup\backup-file-name.zip
                            

  6. The import will ask whether the existing database data should be deleted before proceeding.

  7. Once the import has completed, restart the application server (See the section called “Stopping and Starting the Application Server”).

Performing Offline Backups

Performing an online backup (as discussed above) is a simple and convenient process, but it is sometimes necessary to perform a backup when the application server is not running. For example:

To perform an offline backup:

  1. Stop the application server (See the section called “Stopping and Starting the Application Server”). To ensure all data is captured, the application server must be stopped to perform an offline backup.

  2. Open a command prompt. On a Windows system change to the following directory: [app-path]\server\bin\win\

  3. Run the database export process by executing:

    db-tools export-db

    (This will create an export file in the system backups directory and the filename named with a timestamp).

    The export command has additional options that allows you to specify a different directory or filename. See the section called “export-db Command” for more details.

Export File Retention

Export files in

[app-path]\server\data\backups

will be retained for 30 days and then deleted. This number of days can be changed on the OptionsBackups page under "Keep exports for ... days". This period will automatically be extended should exports not be performed on a regular basis, i.e. when automatic exports have been temporarily disabled for a time or when skipping scheduled exports due to a system outage. Older export files will not be deleted unless a number of new exports have been performed. At the very least the latest export file will always be retained regardless of its age.

Backup Print Archive files

By default the Print Archive is stored in

[app-path]\server\data\archive

and is not included in the database exports detailed above. It is recommended that you consider backing up part or all of the Print Archive with your existing backup processes. As PaperCut is resilient to partial restoration of the Print Archive you may want to backup only a month or two worth of archives. There is a README.txt in the archive directory that explains more about partial backups and the directory structure layout.