How can I restore a MySql database dump direct from S3?

1

I have a gzipped database backup stored on S3 and would like to restore it to MySql without having to first download it due to disk space constraints. I tried the two commands below but got gzip: stdin: not in gzip format both times.

Version 1:

s3cmd get s3://mybucket/mydbbackup.sql.gz | gzip -d | mysql -u root -p

Version 2:

s3cmd get s3://mybucket/mydbbackup.sql.gz - | gzip -d | mysql -u root -p

KalenGi

Posted 2016-03-09T22:21:57.993

Reputation: 129

Pipe it directly into less or something. Do you see something that looks like a mysqldump? What happens if you do s3cmd get s3://mybucket/mydbbackup.sql.gz - | od -x? – Zoredache – 2016-03-09T22:27:12.063

I get a lot of hex output 0000000 7327 3a33 2f2f 6877 7265 7465 626f 7975. What should I be looking for? – KalenGi – 2016-03-09T22:37:08.910

the s3cmd ... | od -x was just to double check you were getting anything at all, and not an error or something, anyway if that gives you something see what you get with your command line, without the pipe into mysql. So s3cmd get s3://mybucket/mydbbackup.sql.gz - | gzip -d What you see should look like a bunch of SQL statements. – Zoredache – 2016-03-10T00:06:06.127

Even this gives me the same error s3cmd get s3://mybucket/mydbbackup.sql.gz - | zcat – KalenGi – 2016-03-10T00:42:17.630

Hrm, I am running low on ideas. How exactly did you make this backup? – Zoredache – 2016-03-10T17:36:41.063

I think the s3cmd output is corrupt. The restore worked when I switched to curl – KalenGi – 2016-03-11T16:26:54.683

No answers