How to post-backup delete the source?
Oneyedrunk :
Jul 10, 2019
Hi everyone,
I don't know much about coding, can someone help me with this?
It would be appreciated.
I'm looking to delete the contents of the source folder after a successful backup run with no errors.
It's a simple backup from A to B that doesn't delete anything on the destination.
Obviously I wouldn't want it to delete anything if there is an error of any kind.
Thanks in advance,
Daniel.
1
Oneyedrunk :
Jul 10, 2019
Update: Oh I figured it might be better if it would Recycle the contents of folder instead of deleting. If that would be possible.
Thanks!
2
Oneyedrunk :
Jul 10, 2019
UPDATE: Have managed to do it with some research and trial and error.
Just made a batch file with
recycle "C:\XYZ\*"
The only issue is I don't know what would happen if there was an error performing the backup. I wouldn't want it to recycle anything that wasn't backed up properly.
Any ideas?
Thanks!
3
Alex Pankratov :
Jul 10, 2019
This is done by making a short .bat file like this:
if NOT "%BVCKUP_status%" == "Completed" exit
if NOT "%BVCKUP_errors%" == "0" exit
recycle "%BVCKUP_src%\*"
That is, put these lines in a text file, save, for example, as C:\Temp\recycle-if-ok.bat and then set post-backup command to
C:\Temp\recycle-if-ok.bat
These "BVCKUP_..." variables are set up by bvckup2 when it starts pre/post-backup scripts. They capture a lot of different details about the backup and the program in general. There's over 80 of them.
They can be inspected by a batch file (just like it's done above) and this can be used to do certain things selectively.
4
audiomutt :
Jun 16, 2020
Does this still work in the most recent release (81.3.1)? I've tried following the instructions above and tweaking a few things but I can't seem to get the folder/files to move to the recycle bin.
5
Alex Pankratov :
Jun 16, 2020
I don't see why it wouldn't. That said, my previous post explains how to check for successful backup completion. I don't know what the "recycle" command is and I don't think it is standard.
If you don't want to delete _to recycle bin_, but rather just delete all at the source right away, then you can replace "recycle ..." line with
del /f /s /q "%BVCKUP_src%\*"
6
audiomutt :
Jun 16, 2020
thanks for the response. I played around a little more and I actually ended up using something slightly different. I wanted to get rid of all the subfolders as well so I used:
if NOT "%BVCKUP_status%" == "Completed" exit
if NOT "%BVCKUP_errors%" == "0" exit
rmdir /s /q "c:\folder_name"
mkdir "c:\folder_name"
rmdir to remove the directory and its contents
mkdir to create the directory again
7
Alex Pankratov :
Jun 16, 2020
Aye, yep. That's another option. You can also give a try to bvckup's little spin-off project called "byenow" -
https://iobureau.com/byenow/