Home>

ubuntu 20 + MySQL on VDS.

Created MySQL database backup to db1.sql.zst archives, ... db10.sql.zst:

mysqldump -uroot user2_db 'table1' --opt --no-create-info --where= 'ID >
0 and ID <
= 20000000 | ZSTD >
 /backup/db1.sql.zst.
...
mysqldump -uroot user2_db 'table1' --opt --no-create-info --where= 'id >
180000000 and ID <
= 200000000 | ZSTD >
 /backup/db10.sql.zst.

BD recovery takes a long time. And the PUTTY terminal can at any time reconnect to the server due to the break of communication (home Internet). Therefore, recovery commands write to the Restore.sh script:

#! /bin /bash
ZSTD -D <
 /backup/db1.sql.zst | mysql -uroot user2_db;
...
zstd -d <
 /backup/db10..sql.zst | mysql -uroot user2_db;

Run it through Crontab -E, and go to sleep). By morning recovery ends.

You need to change the Restore.sh script so that any error messages and warnings from ZSTD and MYSQL are written to the /backup/restore.log file.

How can this be implemented?

I hope correctly understood, add a second string in the script after an interpreter announcement: Exec >>/backup/restore.log 2>&1 -the output of all commands from stdout and stderr in the script will be redirected to write to the /backup/restore.log

PotroNik2021-07-30 12:44:22

Add immediately after "#! /BIN /BASH"? And other scripts will also start writing to this log until you reboot Ubuntu?

Ruport2021-07-30 13:29:59

Yes, on a new line after #! /BIN /BASH, it will only act for the script, which will be made and the reboot will not affect it. Those. The output redirection will be only those commands that are spelled out in the script where this line will add. For the test, what would be clearer, create a script that will return an error, for example, LS /SDSDSDS /and output to Stdout Echo "stdout text", and launch it, see what appeared in the log.

PotroNik2021-07-30 13:46:42