Feature Proposal: Backup & Restore Utility
Motivation
1. TWiki does not have a backup solution. We can raise the professional level of TWiki by adding a robust backup solution.
2. TWiki is known to be hard to upgrade. An intelligent backup & restore utility can be used to easily backup an old TWiki, then restore content to the new TWiki.
Description and Documentation
This proposal is for a new
BackupRestorePlugin that is to be pre-installed in upcoming
IstanbulRelease (TWiki-5.1). The plugin can be installed in older TWiki releases to create a backup that can be restored on the latest release.
Key features
- Operation restricted to members of the TWikiAdminGroup.
- Use dedicated backup directory that holds all backups.
- Backup via cron job and via console screen.
- Restore via console screen.
- Console screen to interactively backup and restore a live TWiki:
- List all backups.
- Delete a backup.
- Restore a backup.
- Create backup now.
Spec
- Topics:
- TWiki.BackupRestorePlugin - plugin doc page.
- TWiki.BackupRestoreConsole - backup & restore page.
- Configuration:
-
{Plugins}{BackupRestorePlugin}{BackupDir} - Backup destination directory. Default: /tmp.
-
{Plugins}{BackupRestorePlugin}{KeepNumberOfBackups} - keep number of backups (e.g. delete old backups), 0 to keep all. Default: 5.
-
{Plugins}{BackupRestorePlugin}{TempDir} - temp directory. Default: /tmp.
-
{Plugins}{BackupRestorePlugin}{createZipCmd} - create zip command. Default: zip -r.
-
{Plugins}{BackupRestorePlugin}{listZipCmd} - list zip content command. Default: unzip -l.
-
{Plugins}{BackupRestorePlugin}{unZipCmd} - unzip command. Default: unzip -o.
-
{Plugins}{BackupRestorePlugin}{Debug} - debug flag. Default: 0.
- Backup names:
-
twiki-backup-2026-01-18-14-32.zip - full backup.
-
twiki-backup-2026-01-18-14-32-incr.zip - incremental backup (for later phase of implementation).
- Script:
-
bin/backuprestore - for cron job; recommended to backup once a week on Sunday early morning
- Interactive backup & restore:
- Done via
%BACKUPRESTORE{}% variable in BackupRestoreConsole page.
- Variable is protect to TWikiAdminGroup members; other users see a message: "Only members of the TWikiAdminGroup can see the backup & restore console."
- Backup format of .zip file:
-
data/* - all data and logs.
-
pub/* - all attachments.
-
working/* - working data.
-
working/BackupRestorePlugin/LocalSite.cfg - TWiki configuration file (if found).
-
working/BackupRestorePlugin/LocalLib.cfg - TWiki lib file (if found).
-
working/BackupRestorePlugin/twiki.conf - Apache config file (if found).
-
working/BackupRestorePlugin/version.txt - contains the TWiki version number of the backup. Used to intelligently restore backup to newer TWiki version. Example:
version: TWiki-5.1.0
short: 5.1
-
working/BackupRestorePlugin/version-long-TWiki-5.1.0.txt - file with TWiki version in filename
-
working/BackupRestorePlugin/version-short-5.1.txt - file with TWiki short-version in filename, name version-short-<major>.<minor>.txt
Console Screen
The following screens are non-working mock-ups.
Main console view
Note:
- Backups are located at
/var/www/twiki-backups
- To upgrade an older TWiki: (1) install the BackupRestorePlugin on the old TWiki, (2) take a backup of the old TWiki, (3) transfer the backup file to the new TWiki's backup directory, (4) select and restore the old backup.
Main console view, while backup is created
Delete backup confirmation
Detail / Restore console screen
Restore from backup confirmation
Attention: Existing topics are overwritten! If applicable, make a backup of the current system before restoring from backup.
Impact
Implementation
Ideas for Enhancements
- Support incremental backup, and restore from incremental backup.
- Upload backup via browser, so that it is easy to migrate a TWiki to a new version via browser.
- Show free disk space.
- Check for disk space, abort and complain if not enough.
- Old Cairo release has locked RCS files. Unlock them before restore.
--
Contributors: PeterThoeny - 2011-01-14
Discussion
A backup/restore function might let us simplify test case development and/or enhance debugging failed testcases. I envision automated backups of the
TestCases Web at the beginning and end of execution of each automated test case but don't yet understand enough about TWiki internals to know if this is feasible. I realize the value of the set_up function (as outlined in the
TestCaseTutorial topic) in "seeding" the required test case test data because it eliminates any dependencies between the test data and what version of of TWiki is being tested, but the matching tear_down function appears to exist only because of the lack of an automated restore. Why require developers to include a function to remove test data if you have a backup of the data itself? In addition not having a copy of the
TestCases Web after execution of each testcase is a disadvantage when debugging.
--
GeorgeTrubisky - 2011-01-17