Answer the question
In order to leave comments, you need to log in
How to set up cron for backups?
Actually, tell me where to dig.
It is necessary at a certain time (perhaps every few hours) to copy certain files and folders to the /mnt/yandexdisk/ folder.
All files at the destination must be replaced.
This begs two questions:
1. How to make a copy through a bash script?
2. How to run bash with cron?
Or is there another solution, more elegant or more interesting :)
Any help would be welcome.
Answer the question
In order to leave comments, you need to log in
1. no need to write any scripts, the copy command can be written directly in the cron.
2. crontab -e
and insert the time and something like rsync -avzh /from /to
. the time can be generated using crontab.guru
and the result should be something like: 0 0 * * * rsync -avzh /from /to
- run backup every day at midnight.
Well, a bicycle has been working for me for a long time, probably since 2000. It was written for FreeBSD, but after a little refinement it took off on linux. True, he solves a more complicated problem - to copy the entire specified directory (or database, though he understands only muscle) to point A, and at point A the previous information can either be overwritten or not overwritten.
Actually, it is pointless to run bash by cron - a simple command can be directly written to the crontab, a complex one - to the script file and the name of this file - to the crontab. Where is the crontab? /etc usually has a crontab file, but it's the "root" crontab that I usually avoid editing. In /etc/cron.d you can create files like
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
*/30 8-17 * * 1-5 root /usr/sbin/my.super.script
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question