Unable to restore from backup


(Timothy Vail) #1

I am trying to restore a backup but it has not been able to unpack or something. I had to totally start a new server and install a fresh discourse because I couldn’t rebuild my app, there was a HTTP request limit error and something else stopping it. I had someone work on it for 3 1/2 hours and we came to the conclusion that it was server Ubuntu related.

Anyhow, all I want is my users, their info, and any custom translations I had for strings and such. All that is in the backup file, but I don’t know how to extract it other than go into notepad and do it all by hand. Can anyone help?

Here is the error

[2017-06-03 01:09:11] Marking restore as running...
[2017-06-03 01:09:11] Making sure /var/www/discourse/tmp/restores/default/2017-06-03-010911 exists...
[2017-06-03 01:09:11] Copying archive to tmp directory...
[2017-06-03 01:09:11] Unzipping archive, this may take a while...
[2017-06-03 01:09:11] Extracting metadata file...
[2017-06-03 01:09:11] Validating metadata...
[2017-06-03 01:09:11] Current version: 20170526125321
[2017-06-03 01:09:11] Restored version: 20170515203721
[2017-06-03 01:09:11] Extracting dump file...
[2017-06-03 01:09:11] EXCEPTION: Failed to extract dump file.
tar: dump.sql.gz: Not found in archive
tar: Exiting with failure status due to previous errors
[2017-06-03 01:09:11] /var/www/discourse/lib/discourse.rb:26:in execute_command'
/var/www/discourse/lib/backup_restore/restorer.rb:234:inblock in extract_dump'
/usr/local/lib/ruby/2.4.0/fileutils.rb:120:in chdir'
/usr/local/lib/ruby/2.4.0/fileutils.rb:120:incd'
/var/www/discourse/lib/backup_restore/restorer.rb:233:in extract_dump'
/var/www/discourse/lib/backup_restore/restorer.rb:41:inrun'
/var/www/discourse/lib/backup_restore/backup_restore.rb:163:in block in start!'
/var/www/discourse/lib/backup_restore/backup_restore.rb:160:infork'
/var/www/discourse/lib/backup_restore/backup_restore.rb:160:in start!'
/var/www/discourse/lib/backup_restore/backup_restore.rb:19:inrestore!'
/var/www/discourse/app/controllers/admin/backups_controller.rb:101:in restore'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-4.2.8/lib/action_controller/metal/implicit_render.rb:4:insend_action'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-4.2.8/lib/abstract_controller/base.rb:198:in process_action'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-4.2.8/lib/action_controller/metal/rendering.rb:10:inprocess_action'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-4.2.8/lib/abstract_controller/callbacks.rb:20:in block in process_action'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:117:incall'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:555:in block (2 levels) in compile'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:505:incall'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:92:in __run_callbacks__'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:778:inrunprocess_action_callbacks'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:81:in run_callbacks'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-4.2.8/lib/abstract_controller/callbacks.rb:19:inprocess_action'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-4.2.8/lib/action_controller/metal/rescue.rb:29:in process_action'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-4.2.8/lib/action_controller/metal/instrumentation.rb:32:inblock in process_action'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.8/lib/active_support/notifications.rb:164:in block in instrument'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.8/lib/active_support/notifications/instrumenter.rb:20:ininstrument'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.8/lib/active_support/notifications.rb:164:in instrument'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-4.2.8/lib/action_controller/metal/instrumentation.rb:30:inprocess_action'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-4.2.8/lib/action_controller/metal/params_wrapper.rb:250:in process_action'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.8/lib/active_record/railties/controller_runtime.rb:18:inprocess_action'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-4.2.8/lib/abstract_controller/base.rb:137:in process'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionview-4.2.8/lib/action_view/rendering.rb:30:inprocess'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rack-mini-profiler-0.10.4/lib/mini_profiler/profiling_methods.rb:102:in block in profile_method'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-4.2.8/lib/action_controller/metal.rb:196:indispatch'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-4.2.8/lib/action_controller/metal/rack_delegation.rb:13:in dispatch'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-4.2.8/lib/action_controller/metal.rb:237:inblock in action'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-4.2.8/lib/action_dispatch/routing/route_set.rb:74:in dispatch'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-4.2.8/lib/action_dispatch/routing/route_set.rb:43:inserve'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-4.2.8/lib/action_dispatch/routing/mapper.rb:49:in serve'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-4.2.8/lib/action_dispatch/journey/router.rb:43:inblock in serve'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-4.2.8/lib/action_dispatch/journey/router.rb:30:in each'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-4.2.8/lib/action_dispatch/journey/router.rb:30:inserve'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-4.2.8/lib/action_dispatch/routing/route_set.rb:817:in call'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rack-protection-1.5.3/lib/rack/protection/frame_options.rb:31:incall'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/omniauth-1.6.1/lib/omniauth/strategy.rb:189:in call!'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/omniauth-1.6.1/lib/omniauth/strategy.rb:167:incall'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/omniauth-1.6.1/lib/omniauth/strategy.rb:189:in call!'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/omniauth-1.6.1/lib/omniauth/strategy.rb:167:incall'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/omniauth-1.6.1/lib/omniauth/strategy.rb:189:in call!'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/omniauth-1.6.1/lib/omniauth/strategy.rb:167:incall'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/omniauth-1.6.1/lib/omniauth/strategy.rb:189:in call!'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/omniauth-1.6.1/lib/omniauth/strategy.rb:167:incall'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/omniauth-1.6.1/lib/omniauth/strategy.rb:189:in call!'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/omniauth-1.6.1/lib/omniauth/strategy.rb:167:incall'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/omniauth-1.6.1/lib/omniauth/strategy.rb:189:in call!'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/omniauth-1.6.1/lib/omniauth/strategy.rb:167:incall'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/omniauth-1.6.1/lib/omniauth/builder.rb:63:in call'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rack-1.6.8/lib/rack/conditionalget.rb:38:incall'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rack-1.6.8/lib/rack/head.rb:13:in call'
/var/www/discourse/lib/middleware/anonymous_cache.rb:138:incall'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-4.2.8/lib/action_dispatch/middleware/params_parser.rb:27:in call'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-4.2.8/lib/action_dispatch/middleware/flash.rb:260:incall'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rack-1.6.8/lib/rack/session/abstract/id.rb:225:in context'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rack-1.6.8/lib/rack/session/abstract/id.rb:220:incall'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-4.2.8/lib/action_dispatch/middleware/cookies.rb:560:in call'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.8/lib/active_record/query_cache.rb:36:incall'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in call'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-4.2.8/lib/action_dispatch/middleware/callbacks.rb:29:inblock in call'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:88:in __run_callbacks__'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:778:inruncall_callbacks'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:81:in run_callbacks'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-4.2.8/lib/action_dispatch/middleware/callbacks.rb:27:incall'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-4.2.8/lib/action_dispatch/middleware/remote_ip.rb:78:in call'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-4.2.8/lib/action_dispatch/middleware/debug_exceptions.rb:17:incall'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-4.2.8/lib/action_dispatch/middleware/show_exceptions.rb:30:in call'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/logster-1.2.7/lib/logster/middleware/reporter.rb:31:incall'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/railties-4.2.8/lib/rails/rack/logger.rb:38:in call_app'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/railties-4.2.8/lib/rails/rack/logger.rb:22:incall'
/var/www/discourse/config/initializers/100-quiet_logger.rb:17:in call_with_quiet_assets'
/var/www/discourse/config/initializers/100-silence_logger.rb:29:incall'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-4.2.8/lib/action_dispatch/middleware/request_id.rb:21:in call'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rack-1.6.8/lib/rack/methodoverride.rb:22:incall'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rack-1.6.8/lib/rack/runtime.rb:18:in call'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rack-1.6.8/lib/rack/sendfile.rb:113:incall'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rack-mini-profiler-0.10.4/lib/mini_profiler/profiler.rb:282:in call'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/message_bus-2.0.2/lib/message_bus/rack/middleware.rb:62:incall'
/var/www/discourse/lib/middleware/request_tracker.rb:73:in call'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/railties-4.2.8/lib/rails/engine.rb:518:incall'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/railties-4.2.8/lib/rails/application.rb:165:in call'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/railties-4.2.8/lib/rails/railtie.rb:194:inpublic_send'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/railties-4.2.8/lib/rails/railtie.rb:194:in method_missing'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rack-1.6.8/lib/rack/urlmap.rb:66:inblock in call'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rack-1.6.8/lib/rack/urlmap.rb:50:in each'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rack-1.6.8/lib/rack/urlmap.rb:50:incall'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/unicorn-5.3.0/lib/unicorn/http_server.rb:606:in process_client'
/var/www/discourse/lib/scheduler/defer.rb:85:inprocess_client'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/unicorn-5.3.0/lib/unicorn/http_server.rb:702:in worker_loop'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/unicorn-5.3.0/lib/unicorn/http_server.rb:549:inspawn_missing_workers'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/unicorn-5.3.0/lib/unicorn/http_server.rb:142:in start'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/unicorn-5.3.0/bin/unicorn:126:in'
/var/www/discourse/vendor/bundle/ruby/2.4.0/bin/unicorn:22:in load'
/var/www/discourse/vendor/bundle/ruby/2.4.0/bin/unicorn:22:in'
[2017-06-03 01:09:11] Trying to rollback...
[2017-06-03 01:09:11] There was no need to rollback
[2017-06-03 01:09:11] Notifying 'Tim' of the end of the restore...
[2017-06-03 01:09:16] Cleaning stuff up...
[2017-06-03 01:09:16] Removing tmp '/var/www/discourse/tmp/restores/default/2017-06-03-010911' directory...
[2017-06-03 01:09:16] Unpausing sidekiq...
[2017-06-03 01:09:16] Marking restore as finished...
[2017-06-03 01:09:16] Finished!

(Andrew Waugh) #2

To add a little background to Tim’s request (Tim and I looked at his instance last night).

(This started at Upgrade error on AWS free tier t2.micro)

I’m pretty sure that Tim’s initial problem was that he built his original instance using a marketplace AMI (Discourse Powered by Intuz) rather than just a Ubuntu base and installing Discourse per the 30 min install.

What we did last night was:

  • Create a fresh instance, using the Ubuntu AMI, (apt update and such to get current)
  • Installed discourse per the 30min install. ./setup-discourse ran perfectly well, as does ./launcher rebuild app, mail works fine.
  • Then we used sftp to copy his old app.yml and his backups from the old instance to the new one, ./launcher rebuild app still works fine, and the box still send emails etc.

Now here is where it gets interesting…

The backup from his old instance contains a dump.sql, and it has (at a glance) ALL of the data from his old instance BUT… when we try to run a restore we get the same type of errors as were causing Tim’s problem in the first place.

So the question is: Given a functioning instance, with a working app.yml, how to we restore just the dump.sql?

My guess is that Intuz did some magic on the backup, and for some reason that magic has now turned into bad juju.


Upgrade error on AWS free tier t2.micro
(Andrew Waugh) #3

Ok, I think I’ve got it. I created an AWS instance using the Intuz AMI which causes the problem, and that wouldn’t update to latest, neither using the web interface, nor the CLI.

To fix it:

sudo -s

Stop the site (if running), either

./launcher stop

or
get the id of the image

docker ps

and then

docker stop _id_

Rename the current directory (mv -r /var/discourse /var/baddiscourse)

Make a new discourse install directory:

mkdir /var/discourse

Install Discourse

git clone https://github.com/discourse/discourse_docker.git /var/discourse

Copy your old data back:

cp -p -r -f /var/baddisourse/shared /var/discourse

Copy your app.yml back:

cp /var/baddiscourse/containers/app.yml /var/discourse/containers/app.yml

Rebuild:

cd /var/discourse
./launcher rebuild app

I can’t remember now if I actually ran discourse-setup after downloading the new discourse install or not, and I may have missed a step or detail, but… This is a way to convert an Intuz install to a regular discourse one. Once the site is back up and you’ve verified that your content is there (and that backups work) your can get rid of the /baddiscourse directory.


(Timothy Vail) #4

Thanks for working on that, I tried to do it on my old instance where I had the original data and it ran into the same error, I’m going to try to download my shared folder and upload it back into my new instance and try that process again, and see if it works.


(Allen - Watchman Monitoring) #5

I tried a bit, and found two things of interest:

I see this in the restore failure:

[2017-06-03 15:36:23] Marking restore as running...
[2017-06-03 15:36:23] Making sure /var/www/discourse/tmp/restores/default/2017-06-03-153623 exists...
[2017-06-03 15:36:23] Copying archive to tmp directory...
[2017-06-03 15:36:23] Unzipping archive, this may take a while...
[2017-06-03 15:36:23] Extracting metadata file...
[2017-06-03 15:36:23] Validating metadata...
[2017-06-03 15:36:23]   Current version: 20170526125321
[2017-06-03 15:36:23]   Restored version: 20170515203721
[2017-06-03 15:36:23] Extracting dump file...
[2017-06-03 15:36:23] EXCEPTION: Failed to extract dump file.
tar: dump.sql.gz: Not found in archive
tar: Exiting with failure status due to previous errors

if the restore process can’t find the dump file, why are there both a Current version and a Restored version ?

Also, the site’s title was

16	title	1	할수가 커뮤니티	2017-05-15 14:20:29.253593	2017-05-19 18:47:35.219035

The backup files had nothing in the prefix before the date & schema version.

EDIT:
Is the lack of standard characters in the title somehow related to the fact these backups can’t be restored? No, it just looks odd.


(Andrew Waugh) #6

I think that the missing site name is because of the Korean.

I have a version of the backup with an intact dump.sql, but it has about 10 VERY long lines which mention credentials… when I try to restore this backup I get error messages mentioning this exact texts:

8512	Jobs::PurgeDeletedUploads	ip-172-31-2-190-app\n	91	20	558527	562516	2017-05-17 13:50:07.516703	f	
Jobs::HandledExceptionWrapper: Wrapped Aws::Errors::MissingCredentialsError: unable to sign request without credentials set /var/www/discourse/app/jobs/base.rb:178:in `perform'\n/var/www/discourse/app/jobs/base.rb:202:in `perform'\n/var/www/discourse/lib/scheduler/manager.rb:95:in `process_queue'\n/var/www/discourse/lib/scheduler/manager.rb:40:in `block in initialize'
8513	Jobs::ProcessBadgeBacklog	ip-172-31-2-190-app\n	91	11	584737	588554	2017-05-17 13:50:51.56666	t	\N

NOTE I added a line break where I think line 8512 should have finished. The error messages I was seeing during the restore were: "unable to sign request without credentials set "


(Timothy Vail) #7

So, if the site title or other required fields are changed to English, then that should let the restore go through with no problems?


(Allen - Watchman Monitoring) #8

sign request to s3? The latest version I helped Tim with had all the s3 settings I could find wiped out…


(Andrew Waugh) #9

I’m not clear on what that line is doing in an sql dump, is it the error log output from the sidekiq job PurgeDeletedUploads???

Is there a way to manually edit the dump file so that it only includes categories, usernames/mails, and posts?

Tim: Did you have S3 setup to store backups or images at any point?


(Allen - Watchman Monitoring) #10

I just tried on a new site… it’s odd that there’s no title at all when the Title is all unicode characters, but the restore works.


(Andrew Waugh) #11

The whole restore works?

Mine set the site title, but that was about it.

Perhaps this dog has fleas and ticks?

The Intuz prebuilt Ami definitely breaks when you try to upgrade to 1.9. Are the restore issues Tim is having a different problem?


(Allen - Watchman Monitoring) #12

Yeah, I’m trying to boil Tim’s problem down to just one… he’s trying a supported platform (DO) now.


(Jay Pfaffman) #13

Put something before the dash at the start of the filename and I think it’ll work. You might need to do some googling to get it to work, as many commands interpret a dash as the beginning of a switch.


(Allen - Watchman Monitoring) #14

On a testing instance i had I set the site title to 할수가 커뮤니티 and made a backup.

I didn’t download or upload it… but tried a restore right away. It worked.

So, it looks odd that we have nothing for a title in the backups, but that in & of itself isn’t a problem.


(Allen - Watchman Monitoring) #15

I was unclear what the restore process would consider “a valid backup” I assume the folder in the tar.gz needs to match the file name, but don’t know what else needs to match.


(Andrew Waugh) #16

I’ve tried TIMSSITE before the dash, I still get exactly the same error message during restore:

[2017-06-03 16:29:09] 'admin' has started the restore!
[2017-06-03 16:29:09] Marking restore as running...
[2017-06-03 16:29:09] Making sure /var/www/discourse/tmp/restores/default/2017-06-03-162909 exists...
[2017-06-03 16:29:09] Copying archive to tmp directory...
[2017-06-03 16:29:09] Unzipping archive, this may take a while...
[2017-06-03 16:29:09] Extracting metadata file...
[2017-06-03 16:29:09] Validating metadata...
[2017-06-03 16:29:09]   Current version: 20170526125321
[2017-06-03 16:29:09]   Restored version: 20170515203721
[2017-06-03 16:29:09] Extracting dump file...
[2017-06-03 16:29:09] Restoring dump file... (can be quite long)
[2017-06-03 16:29:09] SET
[2017-06-03 16:29:09] SET
...snip
[2017-06-03 16:29:14] Waiting for sidekiq to finish running jobs...
[2017-06-03 16:29:14] Switching schemas... try reloading the site in 5 minutes, if successful, then reboot and restore is complete.
[2017-06-03 16:29:14] Migrating the database...
[2017-06-03 16:29:19] EXCEPTION: unable to sign request without credentials set
[2017-06-03 16:29:19] /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/seed-fu-2.3.5/lib/seed-fu/runner.rb:46:in `eval'
...snip
[2017-06-03 16:29:19] Trying to rollback...
[2017-06-03 16:29:19] Rolling back...

(Andrew Waugh) #17

It complains if your change the name of the backup file and remove the part following the -v