--- layout: wiki title: TracBackup updated: 2021-04-16 08:14 author: trac default: true --- ## Trac Backup Trac backups are a copied snapshot of the entire [project environment](/briareus/notes/TracEnvironment/) directory, including the database. Backups can be created using the \`hotcopy\` command of [trac-admin](/briareus/notes/TracAdmin/). **Note**: Trac uses the \`hotcopy\` nomenclature to match that of [Subversion](http://subversion.tigris.org/), to make it easier to remember when managing both Trac and Subversion servers. ### Creating a Backup Create a backup of a live [TracEnvironment](/briareus/notes/TracEnvironment/) by running: ```sh $ trac-admin /path/to/projenv hotcopy /path/to/backupdir ``` The database will be locked while hotcopy is running. The resulting backup directory is safe to handle using standard file-based backup tools like \`tar\` or \`dump\`/\`restore\`. Please note, the \`hotcopy\` command will not overwrite a target directory. When the target exists the operation will end with an error: \`Command failed: 17 File exists:\` This is discussed in #3198. ### Restoring a Backup To restore an environment from a backup, stop the process running Trac, ie the web server or [tracd](/briareus/notes/TracStandalone/), restore the contents of your backup to your [project environment](/briareus/notes/TracEnvironment/) directory and restart the process. If you are using a database other than SQLite, you'll need to restore the database from the dump file. The dump file is saved in the environment \`db\` directory. To restore a PostgreSQL database backup, use the command: ```sh $ psql -U -d -f /path/to/postgresql.dump ``` The \`\` option is the same as the database connection string in the "[trac database"\] option of the project's \`trac.ini\` file. Similarly, for MySQL: ```sh $ mysql -u -p < /path/to/mysql.dump ``` --- See also: [TracAdmin](/briareus/notes/TracAdmin/), [TracEnvironment](/briareus/notes/TracEnvironment/), TracMigrate