Manual backup with command line and restore

AI-generated summary

A user is trying to manually restore a broken Discourse forum to a new server using a backup file, but the restore fails due to a corrupted archive, indicated by a “tar: Unexpected EOF in archive” error. gerhard suggests checking the file integrity by comparing checksums, as the file may have been damaged during transfer. pfaffman recommends creating a new backup on the old server if possible, or using rsync to transfer the entire /var/discourse folder to the new server, including the standalone folder and app.yml. Chopper confirms the old server is non-functional and cannot perform automatic backups. pfaffman advises rsyncing the entire discourse directory to the new machine, and Chopper thanks for the suggestion.

Hello,

I have a broken Discourse forum that I want to move to another server. I have a backup in the folder:

$ ls /var/discourse/shared/standalone/backups/default
$ forum-2019-05-06-033420-v20180920042415.tar

On my new server I try to load the backup but it failed:

$ ./launcher enter app
$ discourse enable_restore
$ gzip public/backups/default/forum-2019-05-06-033420-v20180920042415.tar
$ discourse restore forum-2019-05-06-033420-v20180920042415.tar.gz
Starting restore: forum-2019-05-06-033420-v20180920042415.tar.gz
[STARTED]
'system' has started the restore!
Marking restore as running...
Making sure /var/www/discourse/tmp/restores/default/2019-05-08-180427 exists...
Copying archive to tmp directory...
Unzipping archive, this may take a while...
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now
No metadata file to extract.
Validating metadata...
  Current version: 20190508135348
  Restored version: 20180920042415
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now
Extracting dump file...
EXCEPTION: /var/www/discourse/lib/backup_restore/restorer.rb:264:in `block in extract_dump': Failed to extract dump file.
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now
/var/www/discourse/lib/discourse.rb:29:in `execute_command'
/var/www/discourse/lib/backup_restore/restorer.rb:264:in `block in extract_dump'
/usr/local/lib/ruby/2.6.0/fileutils.rb:128:in `chdir'
/usr/local/lib/ruby/2.6.0/fileutils.rb:128:in `cd'
/var/www/discourse/lib/backup_restore/restorer.rb:263:in `extract_dump'
/var/www/discourse/lib/backup_restore/restorer.rb:58:in `run'
script/discourse:141:in `restore'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
script/discourse:282:in `<top (required)>'
/usr/local/lib/ruby/2.6.0/bundler/cli/exec.rb:74:in `load'
/usr/local/lib/ruby/2.6.0/bundler/cli/exec.rb:74:in `kernel_load'
/usr/local/lib/ruby/2.6.0/bundler/cli/exec.rb:28:in `run'
/usr/local/lib/ruby/2.6.0/bundler/cli.rb:463:in `exec'
/usr/local/lib/ruby/2.6.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/lib/ruby/2.6.0/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/usr/local/lib/ruby/2.6.0/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
/usr/local/lib/ruby/2.6.0/bundler/cli.rb:27:in `dispatch'
/usr/local/lib/ruby/2.6.0/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
/usr/local/lib/ruby/2.6.0/bundler/cli.rb:18:in `start'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-1.17.2/exe/bundle:30:in `block in <top (required)>'
/usr/local/lib/ruby/2.6.0/bundler/friendly_errors.rb:124:in `with_friendly_errors'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-1.17.2/exe/bundle:22:in `<top (required)>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'
Trying to rollback...
There was no need to rollback
Cleaning stuff up...
Removing tmp '/var/www/discourse/tmp/restores/default/2019-05-08-180427' directory...
Unpausing sidekiq...
Marking restore as finished...
Notifying 'system' of the end of the restore...
Finished!
[FAILED]

I don’t now why but the backup from the previous forum is broken and I cannot access to the UI anymore only the command line.

How can a manually get the database and the files from the previous Discourse to the new one ?

The tar backup contains this:

It looks like the backup file has been damaged. Maybe something happened to the file during the transfer to the new server. How did you transfer the file between your servers? Try comparing the checksums of the file on both servers. Are they the same?

You should do what @gerhard said.

Also, if you can access the command line on the old server you can

cd /var/discourse
./launcher enter app
discourse backup

to create a new backup.

You could also rsync the uploads and do an SQL-only backup.

The problem is that the old Discourse is broken. The docker version was to old and the ubuntu was to old too. When rebuilding is was not possible to launch the discourse again. So I cannot do automatic backup only manually.

I try to copy the standalone folder to the new discourse instance and also the app.yml file and rebuild the app but all I have is this page:

Any idea how can I rebuild the discourse with the previous data ?

I’d try rsyncing the whole /var/discourse folder to the new machine (delete the current one on the new machine first and destroy the current docker image).

EDIT: you could be somewhat selective like not copying logs, but simple is simple.

nice, thx :slight_smile: