Take a backup before a change
This task is for administrators before an upgrade, a migration or any change that touches the database. At the end you have a database dump and a file archive taken at the same moment, which is your rollback. Background: What to back up.
Contents
Before you start
- Shell access, the database user and enough disk space on another volume or system.
- Know your engine:
grep -rn "DatabaseImplementation" settings/override settings/siteaccess/*/site.ini.append.php settings/site.ini.
Steps
Switch maintenance on, so database and files match (Take the site into maintenance for an upgrade).
Dump the database (the client asks for the password; never type it on the command line):
Engine Command MySQL, MariaDB mysqldump --single-transaction -u USER -p DATABASE > backup-before-change.sqlPostgreSQL pg_dump -U USER DATABASE > backup-before-change.sqlSQLite sqlite3 var/storage/sqlite3/exponential.db ".backup 'backup-before-change.db'"(your file name)Other engines: Backups per database engine.
Archive the files:
tar czf backup-before-change-files.tgz var/storage settings/override settings/siteaccess extension designCopy both to the backup location, off this server.
On MySQL or MariaDB sites with the git_manager extension, Setup > Backup, Create full site backup is an alternative from the browser; its archives stay on the same server until you move them (Backups from the admin with git_manager).
Check it worked
- The dump ends normally (for MySQL the last line is a
-- Dump completedcomment) and has a plausible size. tar tzf backup-before-change-files.tgz | headlists the files.- Note the file names and sizes in the change record.
Pitfalls
- The audit keys are in
settings/override/audit.ini.append.php: the archive above contains them, so protect it like a secret (Keys and secrets in backups). - Never copy a SQLite file while the site runs; use
.backup. - A backup you have never restored is a hope: Restore last night's backup to a test server.
Related pages
- Back up a SQLite site safely
- Rollback planning
- Upgrading, step 1
- Backups: what to back up (hosting)
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.