Page 1 of 2

DietPi Sync Request

Posted: Mon Feb 18, 2019 11:58 pm
by midnightwatcher
I know there is an option to perform a Dry Run, but when performing an actual sync would it be possible to first perform a quick comparison between sync source and sync destination and then have a simple prompt stating the following:

"Number of files to be deleted: X
Number of files to be copied: X

Do you wish to continue? y/n"

It would be nice to have a simple comparison with a y/n prompt before the sync/backup instead it having to do a full fledged Dry Run.

Re: DietPi Sync Request

Posted: Thu Feb 21, 2019 2:12 pm
by MichaIng
DietPi-Sync already performs a dry run before the actual sync to check sufficient disk space. But the actual sync is done automatically if disk space test succeeds.

However we could indeed merge both:
- Only offer sync, but add info that a dry run with dedicated question to go on is done.
- Do dry run, show log to user and allow to continue or cancel. But this would be a full log. Perhaps we could add a summary as you suggested to the top of the shown log. But exactly those numbers are already printed at the end of the log by rsync.
- However running the script via input dietpi-sync 1 of course would still automate the sync and skip the user prompt, instead exit automatically with error, if free space check did not succeed.

Re: DietPi Sync Request

Posted: Thu Feb 21, 2019 6:17 pm
by midnightwatcher
I like the idea of merging them both. If space is deemed sufficient, the user prompt could be something like:

"Number of files to be deleted: X
Number of files to be copied: X

Do you wish to continue? <Yes> <No> <View Log>"

If the user chooses to View Log, only then would DietPi-Sync run a full log (I'm assuming this would take a little more time than a simple files to be copied and files to be deleted comparison).

Re: DietPi Sync Request

Posted: Thu Feb 21, 2019 6:25 pm
by MichaIng
The log is generated anyway. We use it to determine required disk space. Showing it does not take any recognisable time, but yeah perhaps distracts user, so only sum up the most important info by default.

Re: DietPi Sync Request

Posted: Thu Feb 21, 2019 10:13 pm
by midnightwatcher
Sounds good. It would help people like me who are sometimes too lazy to do a dry run from accidentally deleting the destination drive. (Last week my source drive wasn't mounted properly like I thought. DietPi-Sync thought it was empty and deleted all 7 terabytes of the destination drive. After I figured out what happened I mounted the source drive and did a sync, which took nearly two days to complete).

:o

Re: DietPi Sync Request

Posted: Thu Feb 21, 2019 10:17 pm
by MichaIng
Ui jep. Perhaps we should also add a check, if the source dir is empty, which is in very most cases not what users want to sync :o.

Re: DietPi Sync Request

Posted: Thu Feb 21, 2019 10:50 pm
by midnightwatcher
Excellent idea.

Re: DietPi Sync Request

Posted: Thu Feb 28, 2019 3:09 pm
by midnightwatcher
Should I add this to FeatHub?

Re: DietPi Sync Request

Posted: Thu Feb 28, 2019 3:22 pm
by MichaIng
Not required. I will add this with v6.22:
- Empty source check
- Prompt info after dry run before real sync with rough summary and options to show full sync log, cancel or continue with real sync.
- Remove dedicated dry run option instead.
- When calling automated sync with cmd argument, do real sync directly, in case dry run succeeded and drive space + empty source checks passed.

https://github.com/MichaIng/DietPi/issues/2602

Re: DietPi Sync Request

Posted: Sat Mar 02, 2019 5:53 pm
by MichaIng
@midnightwatcher
I finished the request, including some other minor fixes and enhancements. You can test the new script if you want:

Code: Select all

wget https://raw.githubusercontent.com/MichaIng/DietPi/dev/dietpi/dietpi-sync -O /DietPi/dietpi/dietpi-sync
chmod +x /DietPi/dietpi/dietpi-sync
The changes do not depend on other changes made with v6.22 or even this PR, so you can test this individually. If you face any error or quirks, please report back.

You can always revert to current stable version:

Code: Select all

wget https://raw.githubusercontent.com/MichaIng/DietPi/master/dietpi/dietpi-sync -O /DietPi/dietpi/dietpi-sync
chmod +x /DietPi/dietpi/dietpi-sync