Skip to content

Add documentation for manual backup #2924

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Flux159 opened this issue Apr 4, 2016 · 25 comments
Closed

Add documentation for manual backup #2924

Flux159 opened this issue Apr 4, 2016 · 25 comments
Labels
📖 documentation Documentation needs more love
Milestone

Comments

@Flux159
Copy link

Flux159 commented Apr 4, 2016

Currently, the gogs documentation does not have any documentation on backing up gogs data.

It would be helpful if there was a section covering Administration / Backup practices that also mentions the ./gogs dump command.

As referenced here: https://discuss.gogs.io/t/suggestion-on-repository-load-balancing-and-replication-hot-backup-strategy/182/8

@unknwon unknwon added the 📖 documentation Documentation needs more love label Apr 5, 2016
@unknwon unknwon added this to the 0.10.0 milestone Apr 5, 2016
@Liquidream
Copy link

I would also be very interested in some documentation to help me automate a nightly backup of my Gogs site (data/files/config/etc.) to somewhere like an archive. That I could then send up to a cloud backup or something.
I'm only just starting to use Gogs, but wouldn't want to get complacent and forget to do any backups.
Many thanks.

@laoshaw
Copy link

laoshaw commented May 23, 2016

Same here need docs on how to backup gogs, until then it's just nervous to put gogs for serious use.

@jmgilman
Copy link

jmgilman commented Jul 5, 2016

+1 A well tested method would be appreciated rather than trying to cobble my own together

@unknwon unknwon modified the milestones: 0.10.0, 0.11.0 Jul 16, 2016
@Eng3l
Copy link

Eng3l commented Sep 1, 2016

I made a script that backups my postgresql database, compress my repo directory, pack all and send this pack via ssh to my backup server. Is not complicated at all.

@jmgilman
Copy link

jmgilman commented Sep 1, 2016

The object is identifying what needs to be backed up and the best way to do it. Anyone can just grab and compress everything, but that's not what this issue is about.

@Eng3l
Copy link

Eng3l commented Sep 1, 2016

@jmgilman ok, just saying the way I solved, my backups are up to 1 GB so I can keep an entire month. But is not an elegant solution.

@barbuslex
Copy link

+1

1 similar comment
@jpgreth
Copy link

jpgreth commented Sep 16, 2016

+1

@unknwon
Copy link
Member

unknwon commented Mar 16, 2017

You can use ./gogs backup --database-only --target=./ and ./gogs restore --from=gogs-backup.zip.

Also possible to backup from SQLite3 and restore to MySQL.

@unknwon unknwon closed this as completed Mar 16, 2017
@fake-name
Copy link

So it sounds like gogs backup supports a bunch of arguments (--database-only, --target, --from, etc....). Where are they documented?

What is the difference between gogs dump and gogs backup?

@unknwon
Copy link
Member

unknwon commented Mar 16, 2017

No such command dump right now.

@unknwon
Copy link
Member

unknwon commented Mar 16, 2017

I'm writing a post, should be up soon.

@fake-name
Copy link

Maybe close the issue when it's available?

@fake-name
Copy link

fake-name commented Mar 16, 2017

Ok, trying gogs backup, it fails. This is on a running and functional gogs instance.

gogs@vcssrv:~$ /opt/gogs/gogs backup
2017/03/16 16:18:55 [ WARN] Custom config '/opt/gogs/custom/conf/app.ini' not found, ignore this if you're running first time
2017/03/16 16:18:55 [ INFO] Backup root directory: /tmp/gogs-backup-513963060
2017/03/16 16:18:55 [ INFO] Packing backup files to: gogs-backup-1489706335.zip
2017/03/16 16:18:55 [FATAL] Fail to dump database: fail to dump table 'User': dial tcp 127.0.0.1:3306: getsockopt: connection refused

I have no idea why it's trying 3306, I'm using postgresql, not mysql.

@unknwon
Copy link
Member

unknwon commented Mar 16, 2017

@fake-name apparently you should tell Gogs which custom/conf/app.ini to use. Recommend cd into directory before execute backup.

@fake-name
Copy link

fake-name commented Mar 16, 2017

That's the thing. My gogs server is currently running, and has been being used for ~6 months now. It knows where it's db is.

The config is in /etc/gogs/conf/app.ini, not /opt/gogs/custom/conf/app.ini. For some reason, the normal runtime finds it fine when invoked as gogs web -p 6000.

@unknwon
Copy link
Member

unknwon commented Mar 16, 2017

Custom config '/opt/gogs/custom/conf/app.ini' not found, ignore this if you're running first time

Log already told you custom config file not found.

@unknwon
Copy link
Member

unknwon commented Mar 16, 2017

Please don't just dump questions and errors without stop a second and thinking.

@fake-name
Copy link

fake-name commented Mar 16, 2017

I understand it's not finding it's configuration. My issue is how does it normally determine from where to load it's config? I've been looking through the /usr/bin/gogs bootstrap script, and looked at ps -lafA, and I don't see where the path is being specified at all.

Sure, I can hard-code the ini path in my backup script, but that seems like a bad idea, given that it must be pulling it from somewhere. I'd assume at this point that you can probably specify an environment variable to gogs that tells it where it should get it's config from. I'd like to use that for my backup scripts, so if I wind up moving anything at some point, the backup script will work without having to patch that too.

Maybe this is some oddness related to the packager.io deb process?

@unknwon
Copy link
Member

unknwon commented Mar 16, 2017

@fake-name if you start Gogs with --config flag, everything you do should always carry --config flag.

Default custom directory is under the same directory as Gogs binary, not work directory.

Post is up: https://discuss.gogs.io/t/how-to-backup-restore-and-migrate/991

@fake-name
Copy link

fake-name commented Mar 16, 2017

@fake-name if you start Gogs with --config flag, everything you do should always carry --config flag.

That would make sense, but looking at the gogs running gogs process, it's invocation is only ./gogs web -p 6000, ergo my confusion.

durr@vcssrv:~⟫ ps -lAF | grep -i gogs
4 S gogs      6090     1  0  80   0 - 49825 -      36612   0 Mar09 ?        00:01:49 ./gogs web -p 6000
0 S durr      7088 64843  0  80   0 -  2937 pipe_w  2176   1 16:37 pts/2    00:00:00 grep --color=auto -i gogs
1 S postgres 42256  1092  0  80   0 - 62438 -      12028   0 13:25 ?        00:00:00 postgres: gogs_user gogs 127.0.0.1(41272) idle
1 S postgres 42258  1092  0  80   0 - 62453 -      14020   1 13:25 ?        00:00:00 postgres: gogs_user gogs 127.0.0.1(41274) idle

@unknwon
Copy link
Member

unknwon commented Mar 16, 2017

How did you install Gogs?

@fake-name
Copy link

fake-name commented Mar 16, 2017

Packager.io.

Host system is Ubuntu 14.04 x64. As far as I know, I've changed very little from the defaults, though the original install (more then a year ago) was done manually. I dunno if some really, really old configuration thing is still around or something.

This might be related to the stuff they're dealing with in #2174. That was a config-not-working issue, what I want to know is more why it does work.

@unknwon
Copy link
Member

unknwon commented Mar 16, 2017

You can also specify GOGS_CUSTOM env var for custom directory, that's a secret trick, could explain your situation.

@fake-name
Copy link

fake-name commented Mar 16, 2017

Bingo!

root@vcssrv:/etc# grep -ir gogs_custom .
./gogs/conf.d/other:export GOGS_CUSTOM="/etc/gogs"

 Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
📖 documentation Documentation needs more love
Projects
None yet
Development

No branches or pull requests

9 participants