Failed to restore DB

I was trying to restore my backup to a new server, and it showed some errors.

The log is here: Ubuntu Pastebin

The error maybe:

PG::UniqueViolation: ERROR:  could not create unique index "unique_index_categories_on_slug"
DETAIL:  Key (COALESCE(parent_category_id, '-1'::integer), slug)=(5, ) is duplicated.

I though it could be a DB problem, but I didn’t edit it. Just download the backup tar but restored wrongly.

Please help!

1 Like

There is another thread with similar problem.

It is a strange problem.

Many of us have solved it just by keep trying.

Try it several times and may one of them you don’t have the error.

May be your problem is different but it resembles the database errors we had while restoring.

It seems there is a bug in restoring scripts or spme kind of bug with the postgres database system used.

How strange is this solution…FML
Will it be able to edit the sql file to make it normal?

I mean, if I there any way to ignore the duplicated key?

And after I rebuild to a previous version or a beta version, the log has turned into:

EXCEPTION: Compression::Strategy::ExtractFailed[2019-10-16 07:53:52] /var/www/discourse/lib/compression/strategy.rb:89:in `block in extract_file'
/var/www/discourse/lib/compression/strategy.rb:85:in `open'
/var/www/discourse/lib/compression/strategy.rb:85:in `extract_file'
/var/www/discourse/lib/compression/strategy.rb:26:in `block (2 levels) in decompress'
/usr/local/lib/ruby/site_ruby/2.6.0/rubygems/package/tar_reader.rb:65:in `each'
/var/www/discourse/lib/compression/strategy.rb:18:in `block in decompress'
/var/www/discourse/lib/compression/tar.rb:26:in `get_compressed_file_stream'
/var/www/discourse/lib/compression/strategy.rb:15:in `decompress'
/var/www/discourse/lib/compression/pipeline.rb:26:in `block in decompress'
/var/www/discourse/lib/compression/pipeline.rb:24:in `each'
/var/www/discourse/lib/compression/pipeline.rb:24:in `reduce'
/var/www/discourse/lib/compression/pipeline.rb:24:in `decompress'
/var/www/discourse/lib/backup_restore/restorer.rb:141:in `decompress_archive'
/var/www/discourse/lib/backup_restore/restorer.rb:60:in `run'
/var/www/discourse/lib/backup_restore.rb:166:in `block in start!'
/var/www/discourse/lib/backup_restore.rb:163:in `fork'
/var/www/discourse/lib/backup_restore.rb:163:in `start!'
/var/www/discourse/lib/backup_restore.rb:22:in `restore!'
/var/www/discourse/app/controllers/admin/backups_controller.rb:119:in `restore'

Why is that a problem? I didn’t change anything on the tar file.

Take a look at:

2 Likes

Thank you very much on this extracting thing!

Could you please help me with the duplicated key error? Or is there a way I can fix this sql on psql?

@daniel I think the migration in FIX: Add unique index to prevent duplicate slugs for categories · discourse/discourse@c71da3f · GitHub needs to make sure the column values are unique before creating the unique index.

2 Likes

@Rasin, This should now be fixed as of:

https://github.com/discourse/discourse/commit/7ba914f1e10d90b1e4d25b0ab2427c94df456eae

Thank you for bringing this to our attention and I’m sorry for any inconvenience. Let us know if you have any other problems.

6 Likes

Yes, I have told you: it is an odd thing.

But it worked for several of us as you can read here:

I don’t know if your situation is the same, as the error is similar but not exactly the same.

@usulrasolas has comented that he edited the script with sql sentences to correct it.

But me (and others) have not change anything just tried multiple tries.

It is odd, I know, but may be there are timing or time expiration issues involved.
We don’t know.
Developers are looking at it.

2 Likes

Thank you for all your suggestions! Looking forward to new updates.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.