I trying to do a automatic backup (cron) to a network drive. First piece of the code checks whether the drive is smb mounted.
The second part is the actual backup.
I would like to do some kind of incremental backup every day.
Once a month (like the first day of the month) i would like to do a clean backup.
This is the code I wrote up to now:
I suppose this thing works? mayby someone can confirm as i'm not sure about the date checking thing.
RESULT=$(mount | grep "/Lacie")
#Lacie is my NAS
if ["$RESULT" == ""]
echo "Disk not mounted"
echo "Disk mounted"
if [date +%d == 1]
rsync -avh --delete --progress /home/pieter/Documents /home/pieter/Mounts/Lacie/backup_pieter/
#clean backup: --delete function
rsync -avh --progress /home/pieter/Documents /home/pieter/Mounts/Lacie/backup_pieter/
#incremental backup, without the --delete
I'm slowly building and expanding this small script: The next goal is to keep like 2 complete 'clean' backups, and one that is incrementing (the most recent backup).
How would ik script this?
Is it a good idea to put this in one script that is done everyday? or should i build multiple script files?