How to combine Backup and Sync in one cron script Topic is solved

Having issues with your DietPi installation, or, found a bug? Post it here.
Post Reply
Totila
Posts: 25
Joined: Sun Aug 04, 2019 8:29 am

How to combine Backup and Sync in one cron script

Post by Totila »

Hi fellas,

I was wondering if it was possible to combine a backup with a sync.

I would like to do both one after the other via a script (unattended) launched daily or weekly.

I am aware there are plans to merge dietpi-backup and -sync but as this isnt there yet, I am looking for other ways to backup my dietpi and sync the result from one HDD to another.

I am also aware of the option to enable daily sync within the options of the dietpi-sync but I am afraid that this will collide as cron jobs are triggered in parallel. So the backup via a script within cron.daily (Taken from another forum post) might run at the same time as sync which might lead to incorrect results.

I guess my question is can I combine dietpi-backup and dietpi-sync in one script I put into cron.daily?
I tried but the logfile I try to write to doesnt update which makes me think I am overseeing something and the commands cannot bei combined easily.

Thanks in advance!
User avatar
MichaIng
Site Admin
Posts: 2294
Joined: Sat Nov 18, 2017 6:21 pm

Re: How to combine Backup and Sync in one cron script

Post by MichaIng »

You could add both command calls to the same crontab/script, like:

Code: Select all

#!/bin/dash
/DietPi/dietpi/dietpi-backup 1 || exit 1
/DietPi/dietpi/dietpi-sync 1 || exit 1
exit 0
So the correct order and no concurrency is guaranteed.
Daily sync of course needs to be disabled then for dietpi-sync.
Totila
Posts: 25
Joined: Sun Aug 04, 2019 8:29 am

Re: How to combine Backup and Sync in one cron script

Post by Totila »

Excellent.

I will give this a try a report back.

Thank you very much in advance.
Totila
Posts: 25
Joined: Sun Aug 04, 2019 8:29 am

Re: How to combine Backup and Sync in one cron script

Post by Totila »

Test was successful.

Works like a charme. :)
Post Reply