How to backup, restore and migrate #6876
Replies: 4 comments 3 replies
-
When running gogs inside a Docker container (named 'gogs' in my case) I use:
This first removes old back-ups inside the container, then makes a new back-up inside the docker container, copies the file to the current location (outside the container) and removes the backup from within the container again. It also makes an MD5 hash of the made back-up. Inspired by: #4339 |
Beta Was this translation helpful? Give feedback.
-
I ran restore command with success. I checked the db and see it has restored the users and it has restored the repositories. However, I cannot login to my account. It returns error that username or password is incorrect. I checked the user table and see the users, but the password field is blank. Perhaps that's the issue. Shouldn't the restore operation restore user passwords also. Hoping there is a fix for this. Kindly advise. Thank you. |
Beta Was this translation helpful? Give feedback.
-
Unfortunately, nobody on gogs offers to help so I ditched it. I moved over to gitea on docker and it's superior. |
Beta Was this translation helpful? Give feedback.
-
what i did for gogs helm chart: kubectl exec -n gogs <pod name> -- bash -c "HOME=/data/git USER=git /app/gogs/gogs backup --target /backup"
kubectl cp -n gogs <pod name>:/backup/<file> ./<file> in destination gogs (make sure its running 1/1): kubectl cp -n gogs ./<file> <pod name>:/backup/<file>
kubectl exec -n gogs <pod name> -- bash -c "mkdir /data/tmp; HOME=/data/git USER=git /app/gogs/gogs restore --from /backup/<file> -t /data/tmp; chown -R git:git /data" |
Beta Was this translation helpful? Give feedback.
-
Other than pack up
gogs-repositories
,data
,custom
and database separately, Gogs provides two commands for unified process of backup, restore and even migrate to another database engine, because the backup format is database-agnostic.Prerequisite
Backup
Go to the directory where your Gogs binary is located, and execute following command:
Without any flags,
backup
command will pack up allgogs-repositories
,data
,custom
and database into a single zip archive (e.g.gogs-backup-xxx.zip
) under the current directory.It could be a bad idea if your
gogs-repositories
contains GB of raw data, in that case, you can apply--exclude-repos
flag:If your
custom/conf/app.ini
is somewhere unusual, make sure you specify it via--config
flag like always:Database
If you're only interested in backup your database, or want to migrate from one database engine (e.g. SQLite3) to another engine (e.g. PostgreSQL),
--database-only
is your friend:The backup format of database are portable JSON files, each file corresponds to a database table, you can do whatever you want with those files.
Restore
The
restore
command also has flags to indicate only restore database or everything in backup archive:If a table that is not presented in backup archive, whatever in current database table will remain unchanged.
Custom config file
There are 2 steps to determine which
custom/conf/app.ini
command uses:If both steps failed, sorry, impossible to perform restore process.
Beta Was this translation helpful? Give feedback.
All reactions