New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Comments
crontab -e
0 2 * * 1 mysqldump -u admin -p journal > journal.sql
This should run at 2:00am every monday.
apt-get install automysqlbackup
Some improvements:
(1) I'd use the full path to mysqldump because otherwise cron might not find it.
(2) Also, before this like put
MAILTO="[email protected]"
to get email if the job fails.
(3) journal.sql might not end up where you expect it to be, so I'd full path it
(4) And you could get fancy with something like:
0 2 * * 1 /usr/bin/mysqldump -u admin -p journal > /safe/place/journal.$(date '+%Y-%m-%d').sql
which would put each backup in a separate file like
journal.2023-07-10.sql
Do I include the password since I would not enter it when the Job runs.
Thank you for the information!
No you should use a .my.cnf file
e.g., in /root/.my.cnf (be sure to set to mode 600)
[client]
user=root
password="ILoveLowEndTalk"
[mysql]
user=root
password="ILoveLowEndTalk"
[mysqldump]
user=root
password="ILoveLowEndTalk"
Maybe only the mysqldump section is needed for mysqldump.
might be handy for future use
https://crontab.guru/
If db is bussy, it should be locked before dump to avoid half baked data in the tables. Boy, do I had pleasure to backup zabbix gygabytes of mysql crap...
Very nice thanks!