Skip to main content
27 events
when toggle format what by license comment
Aug 30, 2021 at 12:06 comment added Stephen Kitt Yes, cron jobs only run if cron itself is running at the exact time the job specifies. anacron makes up for that by keeping track of when jobs last ran, managing jobs per “time unit” (daily, weekly, monthly) instead of tracking specific times, and running them if cron hasn’t run them in the last day/week/month.
Aug 30, 2021 at 11:57 comment added JConstantine So, the manually created cron jobs won't work as well if the system is off and the only way to deal with that is to use anacron, right? Thank you for all the information you've provided. You helped a lot! And sorry for such an extended discussion in the comments.
Aug 30, 2021 at 11:44 comment added Stephen Kitt Apologies, the version of automysqlbackup in 20.04 doesn’t support DOMONTHLY. Monthly backups always happen on the first day of the month (and will be missed if the system isn’t running on that day).
Aug 30, 2021 at 10:50 comment added Stephen Kitt The man page is unfortunately incomplete. If your system isn’t always on, anacron would be appropriate (instead of trying to find a time when it is guaranteed to be on).
Aug 30, 2021 at 10:28 comment added JConstantine Accroding to the documentation there's no DOMONTHLY. 6:25 is not appropriate because I'm currently working on a temporary machine that is not always powered on and at 6:25 in the morning it is actually powered off. That's why I need to change the time.
Aug 30, 2021 at 10:22 comment added Stephen Kitt There’s DOMONTHLY as well. And yes, you can’t change the time without changing the cron job; is 6:25 not appropriate?
Aug 30, 2021 at 10:13 comment added JConstantine There's DOWEEKLY where I can pick the day of the week, but I can't see a way to pick the day of the month to do monthly backups. Also I don't see how can I set the exact time without using cron jobs.
Aug 30, 2021 at 9:58 comment added Stephen Kitt Incidentally, automysqlbackup also rotates backups for you, so you might not need to delete anything. It keeps all monthly backups, the last five weekly backups, and the last week’s daily backups.
Aug 30, 2021 at 9:57 comment added Stephen Kitt I can’t read those articles’ authors minds ;-). The second one is from 2012, perhaps the package changed since then. The first one discusses the AutoMySQLBackup tool itself, not the package — it’s the Debian (and Ubuntu) package which sets up the cron jobs for you.
Aug 30, 2021 at 9:48 comment added JConstantine I wonder why would they recommend running cron jobs for automysqlbackup out there on many different resources like this or this for example if automysqlbackup is a self-contained utility that can do all those things without using any cron jobs at all.
Aug 30, 2021 at 9:37 comment added Stephen Kitt No, you don’t need another cron job for that, you can use automysqlbackup’s features. Again, look in /etc/defaults/automysqlbackup — you can use a POSTBACKUP script.
Aug 30, 2021 at 9:35 comment added JConstantine The thing is that I want it to run at certain time and then to delete the old backups. So I'll have to set another cron job like: find /home/username/private_files/backups/* -mtime +30 -exec rm {} \;
Aug 30, 2021 at 9:34 comment added Stephen Kitt If you do want to change the defaults, look in /etc/defaults/automysqlbackup.
Aug 30, 2021 at 9:32 comment added Stephen Kitt As explained in the package description, “automysqlbackup creates backup every day, week and month for all of your MySQL database, to a configured folder. There's nothing to do but to install this package, and you'll rest assured that you have a way to go back in the history of your database.” It really is an “install-and-forget” package: you don’t need to configure anything.
Aug 30, 2021 at 9:31 comment added Stephen Kitt I don’t think you need anything else for weekly and monthly backups, automysqlbackup takes care of them when run daily.
Aug 30, 2021 at 9:30 comment added Stephen Kitt If you want to have all your cron.daily jobs run at a different time, then yes.
Aug 30, 2021 at 9:26 comment added JConstantine So, if I want to use the script from the cron.daily for automysqlbackup I just have to modify the /etc/crontab file and change 25 6 * * * to whatever values I need, right? And I want to set the daily/monthly backups as well I'll have to create /etc/cron.weekly/automysqlbackup, /etc/cron.monthly/automysqlbackup files and modify the corresponding lines in /etc/crontab.
Aug 30, 2021 at 9:21 comment added Stephen Kitt Ah right, you don’t have anacron installed (which is fine). The crontab entry tests to see whether anacron is installed, and if it isn’t, runs the cron.daily entries using run-parts.
Aug 30, 2021 at 9:20 comment added JConstantine man anacron returns No manual entry for anacron for me. Also find / -iname 'anacron' returns nothing.
Aug 30, 2021 at 9:16 history edited Stephen Kitt CC BY-SA 4.0
Missing word.
Aug 30, 2021 at 9:15 comment added Stephen Kitt anacron (see man anacron) is a utility which ensures jobs are run at certain intervals, even if the system is powered down. See also Is it true that “cron.daily runs anacron everyhour”?, How does anacron determine daily, weekly and monthly job to run?, How does anacron work if it's not a daemon? and related posts.
Aug 30, 2021 at 9:11 comment added JConstantine And the last thing. I don't understand the following: 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) which is placed inside the /etc/crontab file and actually runs the automysqlbackup utility daily at 6:25 AM. What is anacron?
Aug 30, 2021 at 9:08 comment added Stephen Kitt See the update. The existing cron.daily job will run once a day, using whatever configuration you’ve defined for automysqlbackup. It should work just fine for your purposes.
Aug 30, 2021 at 9:07 history edited Stephen Kitt CC BY-SA 4.0
Explain the commands in more detail.
Aug 30, 2021 at 8:57 vote accept JConstantine
Aug 30, 2021 at 8:57 comment added JConstantine What I want to achieve is to make backups everyday at certain time and delete all the backups older than 30 days. Also I wonder why I couldn't find any information on the exit command. I tried man exit, but nothing was found. Doesn't the || stand for logical OR here? Isn't #!/bin/sh just a comment here?
Aug 30, 2021 at 8:47 history answered Stephen Kitt CC BY-SA 4.0