I want to import the backup database file in *.sql.gz to my backup server. I try to use the follow command but there is an error with it
ls -Art *.sql.gz | tail -n 1 | gunzip -c | mysql --user=user --password=password database
gzip: stdin: not in gzip format
So how can I pipe the latest files to gunzip is correct.
Try using xargs
:
ls -Art *.sql.gz |tail -n 1 |xargs gunzip -c | mysql --user=user --password=password database