You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

backup-and-restore.en-us.md 3.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. ---
  2. date: "2017-01-01T16:00:00+02:00"
  3. title: "Usage: Backup and Restore"
  4. slug: "backup-and-restore"
  5. weight: 11
  6. toc: true
  7. draft: false
  8. menu:
  9. sidebar:
  10. parent: "usage"
  11. name: "Backup and Restore"
  12. weight: 11
  13. identifier: "backup-and-restore"
  14. ---
  15. # Backup and Restore
  16. Gitea currently has a `dump` command that will save the installation to a zip file. This
  17. file can be unpacked and used to restore an instance.
  18. ## Backup Command (`dump`)
  19. Switch to the user running Gitea: `su git`. Run `./gitea dump -c /path/to/app.ini` in the Gitea installation
  20. directory. There should be some output similar to the following:
  21. ```none
  22. 2016/12/27 22:32:09 Creating tmp work dir: /tmp/gitea-dump-417443001
  23. 2016/12/27 22:32:09 Dumping local repositories.../home/git/gitea-repositories
  24. 2016/12/27 22:32:22 Dumping database...
  25. 2016/12/27 22:32:22 Packing dump files...
  26. 2016/12/27 22:32:34 Removing tmp work dir: /tmp/gitea-dump-417443001
  27. 2016/12/27 22:32:34 Finish dumping in file gitea-dump-1482906742.zip
  28. ```
  29. Inside the `gitea-dump-1482906742.zip` file, will be the following:
  30. * `app.ini` - Optional copy of configuration file if originally stored outside of the default `custom/` directory
  31. * `custom` - All config or customization files in `custom/`.
  32. * `data` - Data directory in <GITEA_WORK_DIR>, except sessions if you are using file session. This directory includes `attachments`, `avatars`, `lfs`, `indexers`, sqlite file if you are using sqlite.
  33. * `gitea-db.sql` - SQL dump of database
  34. * `gitea-repo.zip` - Complete copy of the repository directory.
  35. * `log/` - Various logs. They are not needed for a recovery or migration.
  36. Intermediate backup files are created in a temporary directory specified either with the
  37. `--tempdir` command-line parameter or the `TMPDIR` environment variable.
  38. ### Using Docker (`dump`)
  39. There are a few caveats for using the `dump` command with Docker.
  40. The command has to be executed with the `RUN_USER = <OS_USERNAME>` specified in `gitea/conf/app.ini`; and, for the zipping of the backup folder to occur without permission error the command `docker exec` must be executed inside of the `--tempdir`.
  41. Example:
  42. ```none
  43. docker exec -u <OS_USERNAME> -it -w <--tempdir> $(docker ps -qf "name=<NAME_OF_DOCKER_CONTAINER>") bash -c '/app/gitea/gitea dump -c </path/to/app.ini>'
  44. ```
  45. *Note: `--tempdir` refers to the temporary directory of the docker environment used by Gitea; if you have not specified a custom `--tempdir`, then Gitea uses `/tmp` or the `TMPDIR` environment variable of the docker container. For `--tempdir` adjust your `docker exec` command options accordingly.
  46. The result should be a file, stored in the `--tempdir` specified, along the lines of: `gitea-dump-1482906742.zip`
  47. ## Restore Command (`restore`)
  48. There is currently no support for a recovery command. It is a manual process that mostly
  49. involves moving files to their correct locations and restoring a database dump.
  50. Example:
  51. ```none
  52. apt-get install gitea
  53. unzip gitea-dump-1482906742.zip
  54. cd gitea-dump-1482906742
  55. mv custom/conf/app.ini /etc/gitea/conf/app.ini # or mv app.ini /etc/gitea/conf/app.ini
  56. unzip gitea-repo.zip
  57. mv gitea-repo/* /var/lib/gitea/repositories/
  58. chown -R gitea:gitea /etc/gitea/conf/app.ini /var/lib/gitea/repositories/
  59. mysql -u$USER -p$PASS $DATABASE <gitea-db.sql
  60. # or sqlite3 $DATABASE_PATH <gitea-db.sql
  61. service gitea restart
  62. ```