How to backup, restore and migrate


#21

My gogs version is :

Gogs version 0.11.29.0727

(the version number is the same as the latest).
I unziped the backup file,the sessions dir are included.
image

Thank you very much for your help and patience.


#22

Thanks! I think you can file an issue on GitHub as a record, because from the code backup should only include “attachments” and “avatars” subdirs under “data” directory.


#23

Hello @all.

I’m new to Gogs, also to git. So my question may be somehow strange. But I’ve got a curious problem. I’ve setup Gogs on Win 7 Pro 64 bit. It’s running as a service on this Windows box. Then I’ve wrote a simple batch file to get a backup of Gogs configs and also the repositories. The problem: The batch works fine when I’m logged on to the system. But running exactly the same batch from task scheduler, it looks like that the command gogs.exe backup will not create the backup in non-interactive mode.

First I thought it may caused by the user. But I’ve testet this with several users with the same result…

Does anybody here got the same experience? Or does anybody know any hints to solve the problem?

Regards

ThirtySomething

PS: The batch looks like this one

@echo off
d:
cd \gogs
d:\gogs\gogs.exe backup
xcopy gogs-backup-*.zip \\server\development\backup\gogs\ /c /v /y /j
del /f /q gogs-backup-*.zip
echo.
cd \

#24

Sorry, forgot most important information: I’m running Gogs in version 0.11.19.0609.


#25

还原时,提示:
[root@switch-subversion /home/git]# su - git -c "/opt/gogs/gogs restore --from=gogs-backup-20170919104250.zip"
2017/09/19 10:56:33 [ INFO] Restore backup from: gogs-backup-20170919104250.zip
2017/09/19 10:56:40 [FATAL] Fail to import ‘custom’: rename /tmp/gogs-backup/custom /opt/gogs/custom: invalid cross-device link

/opt和/tmp确实是在不同的磁盘上

报错:
invalid cross-device link
不可用的硬链接,没办法,我们采用了不同的磁盘
解决:
不过可以指定临时目录–tempdir=/opt/gogs/tmp
mkdir /opt/gogs/tmp
chown git:git /opt/gogs/tmp

权限不对:
[FATAL] Fail to extract ‘repositories.zip’: open 省略: permission denied
解决:
chmod u+w -R /opt/gogs-repositories/

成功还原的的过程:
chown git:git /opt/gogs
mkdir /opt/gogs/tmp
chown git:git /opt/gogs/tmp
mv /opt/gogs/custom.bak /root/recycle_bin/
chmod u+w -R /opt/gogs-repositories/
su - git -c “/opt/gogs/gogs restore --config=/opt/gogs/custom/conf/app.ini --tempdir=/opt/gogs/tmp --from=gogs-backup-20170919104250.zip”

还原之后,代码确实恢复了,但发现“版本发布”即已推送的标签tag还在


#27

备份详细帮助:
su - git -c "/opt/gogs/gogs backup -h"
NAME:
gogs backup - Backup files and database

USAGE:
gogs backup [command options] [arguments…]

DESCRIPTION:
Backup dumps and compresses all related files and database into zip file,
which can be used for migrating Gogs to another server. The output format is meant to be
portable among all supported database engines.

OPTIONS:
–config value, -c value Custom configuration file path (default: “custom/conf/app.ini”)
–verbose, -v Show process details
–tempdir value, -t value Temporary directory path (default: “/tmp”)
–target value Target directory path to save backup archive (default: “./”)
–archive-name value Name of backup archive (default: “gogs-backup-20170919114931.zip”)
–database-only Only dump database
–exclude-repos Exclude repositories

可以指定备份目标目录:
su - git -c “/opt/gogs/gogs backup --tempdir /opt/gogs/tmp --target /opt/gogs_bak/”

还原的详细帮助:
su - git -c "/opt/gogs/gogs restore -h"
NAME:
gogs restore - Restore files and database from backup

USAGE:
gogs restore [command options] [arguments…]

DESCRIPTION:
Restore imports all related files and database from a backup archive.
The backup version must lower or equal to current Gogs version. You can also import
backup from other database engines, which is useful for database migrating.

If corresponding files or database tables are not presented in the archive, they will
be skipped and remain unchanged.

OPTIONS:
–config value, -c value Custom configuration file path (default: “custom/conf/app.ini”)
–verbose, -v Show process details
–tempdir value, -t value Temporary directory path (default: “/tmp”)
–from value Path to backup archive
–database-only Only import database
–exclude-repos Exclude repositories


#28

I’ve done a successful backup, but now trying to restore it and getting this.

2 things:

  • I’m performing the backup on one instance, and restoring it on another (new, empty) instance
  • both instances are running in Docker containers.

a25ff52a1650:/app/gogs$ ./gogs restore --from /data/gogs
gogs/ gogs-backup-20170919192203.zip
a25ff52a1650:/app/gogs$ ./gogs restore --from /data/gogs-backup-20170919192203.zip
2017/09/19 19:37:01 [ INFO] Restore backup from: /data/gogs-backup-20170919192203.zip
2017/09/19 19:37:27 [FATAL] Fail to import database: fail to insert strcut: database disk image is malformed