Cron Job Question
Rather simple really, but wanted to get some feedback here.
I need to create a cronjob that runs nightly and backups up certain directories. I was going to place it in my /home partition for now, until I can copy it to another location. Few questions: This cronjob will need to run nightly. Secondly, will it overwrite the previous nights backup if I don't specifically cut/move the day before? Lastly, would it be best to use a script to do my job? I basically need to backup one big directory and figured I would just use tar; like so: tar -czf /home/tarballed/backup.tar.gz /path/to/location The cronjob (which I was going to setup with a user who has complete sudo access: would be: crontab -e 0 2 * * * tar -czf /home/tarballed/backup.tar.gz /path/to/location That way, it would run every night at 2am? How would I exclude Saturday and Sunday? Is it ok to just specifiy the command like above? Or would it be better to put it in a simple sscript? Just looking for some feedback/recommendations/changes to this. |
Hi,
I think it'd be easier to write a script like the following: Code:
#!/bin/bash I recommend you set this script to run using crontab. For a quick tutorial which should teach you what you want to do, read this: http://www.tech-geeks.org/contrib/md...ntab-howto.htm Cheers, -jk ;) |
This command will overwrite your previous backup, what you need to do is create a script and put it in the crontab.
For example: 0 2 * * 1-5 root /home/my/script I think this solve your problem. |
Quote:
However, in this case, you will need to watch out with the increasing number of backups.. As I have not put anything in the script to delete backups which are x days old ;) |
Quote:
Perfectly :) |
All times are GMT -5. The time now is 12:21 AM. |