Versioning - Batchfile for cleanup

Discuss new features and functions
Posts: 12
Joined: 22 Nov 2017

ipconfig

Hello All,

I am new in the Forum but using FFS now for over 5 years...

I recently got a NAS and now I am looking for versioning of files as part of a backup scenario.
I read the Forum and several topics that have been related to versioning and the 2 possibilities:

the file name will be extended by the timestamp (Versioning and naming convention Time stamp)
OR
for a timestamp a new folder structure will be created (Versioning and naming convention Replace)

I know about the problems for Zenju to introduce the often discussed features:
"I want to delete everything older than x, but at least y copies should exist (even they are older than x)"

There have been a lot of topics related to that and they nearly closed all with:
Most users have a batch/exe/vbs that will be executed, once synchronisation has been finished or which is executed as a windows task once a day/whatever.

My question to you is:
will you share your cmd/batch/exe/vbs with me?

My goal is really like this:
"I want to delete everything older than x, but at least y copies should exist (even they are older than x)"

I would x set to 1 month and y to 3 because this would fit my requirements perfectly.

my current setup is:
My PC (win 10)+ PC of my wife (win 10):
FFS is triggered by RTS.
RTS is watching for C:\Users\xxx\Desktop, Documents, Pictures, Music...
And because of outlook:
C:\Users\xxx\AppData\Local\Microsoft\Outlook
I use Time stamp versioning because for me this provides a nice overview for a specific file without jumping through different folders where maybe is or not is a older version of a specific file.

since my ost file has the size of about 1.7 GB i don't want to have unlimited versions of that file available.
I stumbled multiple times over a simple line of command that is able to delete folders that are older than x:
forfiles -p "C:\Folder you want to prune" -s -m *.* -d -7 -c "cmd /c del @path"

But this won't fit my needs either since at some point in time i would loose older versions of files that change less often.

Please give me some hints or examples that you use.

@Zenju:
I though about your approach of using Macros in naming convention Replace.
You already introduced: %weekday% (works similar as the number of historie copies is 7) and %day% (works similar as the number of historie copies is 31).
Why not introduce a macro %index,N% ?
index is the keyword for you that you need to look for the value of N.
e.g. %index,3%
would behave like this:
1st change:
C:\Revisions\1\Folder\File.txt

2nd change:
C:\Revisions\2\Folder\File.txt

3rd change:
C:\Revisions\3\Folder\File.txt

4th change:
C:\Revisions\1\Folder\File.txt

--> you can probably just use modulo operator on a counter for the number of executed sync tasks (Does this make sense?)

Keep up the good work and thank you very much!
Anyway!
I love the work and effort you spend into this project.
Posts: 51
Joined: 13 May 2017

Lady Fitzgerald

Something like this included in FFS would be a nice, future upgrade. I spend quite a bit of time hunting down and deleting older files in my Versioning folder to keep it from growing far too big for the space I have for it.
Posts: 12
Joined: 22 Nov 2017

ipconfig

Hmm... I guess I will write something during Christmas holiday...
Posts: 51
Joined: 13 May 2017

Lady Fitzgerald

God Bless your heart (and all your other internal organs)! Please keep in mind when you write something that not everyone is a geek and many of us (especially me) need a simple interface and full, detailed instructions on how to use it.
Posts: 12
Joined: 22 Nov 2017

ipconfig

Happy New Year!

I wrote a small exe file that will be used via commandline and has 2 parameters:
1st the Revisionsdirectory
2nd the numbers of copies to be kept

For now it will work under the following requirements:
In synchronization settings, set deletion handling to Versioning and naming convention to Time stamp.
for example you selected directory Z:\Versioning

My EXE could be called like this:
FFSVersionCleaner "Z:\Versioning" "4"

In this case it will check in Z:\Versioning for versions of the same file. If there are more than 4 Versions the oldest versions will be deleted.
It will also scan through nested subdirectories recursively...

I used it on my NAS and it worked well.
1819 files found. 460 files deleted.
Size was removed from 50 GB to 12 GB since I versioned also my outlook ost file...

Things i would like to ask you:
How can i share the file and will you provide me feedback on how it worked for you or which features you like.
I can also share the source code so you can build on your own...

currently the commands ? help -help will respond with german texts. The same is true for errorhandling e.g. wrong number of parameter, or non existent directory...

BR
ip
User avatar
Posts: 2286
Joined: 22 Aug 2012

Plerry

Effectively, you are reviving a : very old discussion in which I also expressed my preferences and a further clarification.

Unfortunately (at least for you and me) it seems Zenju has since then not seen the need to give priority to having better control over versions, so the status of this is pretty much as it was end 2012.
Nevertheless, I am still very much interested in a good solution.
Although your script only covers part of my needs (as it only covers the number of previous versions, and does not take the "age" thereof into account) I am for sure interested in your source code. This in order to possibly adapt the code to include the "age" aspect.
Posts: 12
Joined: 22 Nov 2017

ipconfig

For now I hosted sourcecode and EXE here:

https://github.com/ipConfigerer/FFSVersionCleaner

As for your origin requirement I got even some more crazy ideas:
Size, Age, Filetype and defaultvalues as a Key-value-list:
e.g.:
default:3>age:100 type:docx-10 type:jpg-2 size:5-8 size:100-5

the parmeters above will be interpreted from left to right, meaning the first criteria that is met will be used and further processing of the parmeters doesn't take place:
default:3>age:100 --> keep at least 3 versions. Else keep all versions from the last 100 days
if the currently processed file is of filetype docx, 10 versions will be kept
if the currently processed file is of filetype jpg, 2 versions will be kept
if the currently processed file has a size of 0 to 5 MB, 8 versions will be kept
if the currently processed file has a size of 0 to 100 MB, 5 versions will be kept

in contrast to the very first parameter
default:5<age:60 --> if no further criteria is met, keep up to 5 versions. Could be less if they are older than 60 days
default:7 --> if no further criteria is met, exactly 7 versions will be kept
age:180 --> if no further criteria is met, delete every version that is older than 180 days

There could even again be several defaults:
default:10<age:30 default:5<age:180
default:3
That would mean that in case of files younger than 30 days it will keep up to 10 copies, if younger than 180 days it will keep 5 copies and older than that 3 copies

What do you think? Rocketscience?
Last edited by ipconfig on 03 Jan 2018, 06:20, edited 2 times in total.
Posts: 12
Joined: 22 Nov 2017

ipconfig

rereading my post over and over again tells me that a configuration UI might be needed...
Posts: 2
Joined: 4 Jan 2018

korbi

Interesting topic! I would love for the following options to be possible:
Keep all versions that are younger than 7 days AND
Keep a version for every of the last 4 weeks AND
Keep a monthly version for the last 6 months AND
Keep yearly versions

So if I would change the file daily and have the backup running for e.g. 2 years I would have 7 + 4 + 6 +2 versions. Would that be possible?
Posts: 12
Joined: 22 Nov 2017

ipconfig

Interesting idea!

As I described the parameters would be:
default:9999999<age:7 default:1<age:28 default:1<age:180 default:1<age:360 default:1<age:720 default:1<age:1080...

I am still thinking about how to combine things with size and filetype or even filetype groups....

By the way: in your example it could also be 8965 depending on how many versions you have in the first 7 days...
Posts: 51
Joined: 13 May 2017

Lady Fitzgerald

So far, I haven't understood a thing being posted. Not all of us are programmers.
Posts: 2
Joined: 4 Jan 2018

korbi

Interesting idea!

As I described the parameters would be:
default:9999999<age:7 default:1<age:28 default:1<age:180 default:1<age:360 default:1<age:720 default:1<age:1080...

I am still thinking about how to combine things with size and filetype or even filetype groups....

By the way: in your example it could also be 8965 depending on how many versions you have in the first 7 days... ipconfig, 04 Jan 2018, 21:31
Ah ok, so your default thresholds are summed up? Or better are to be unterstood as intervalls?
default:10<age:7 default:1<age:14 default:1<age:21
Would mean:
Keep 10 versions younger than 7 days
1 that is older than 7 AND younger than 14
1 that is older than 14 AND younger than 21
In total it would keep 12 files, correct?

This would be exactly what I am looking for :)

Re regarding my earlier example: The keywords were "change daily" ;)
Posts: 12
Joined: 22 Nov 2017

ipconfig

This is exactly the parameter setting... however i am still puzzling out how this can be combined with either documenttype and/or filesize.

E.G. my wife is a teacher and works a lot with docx/xlsx. Usually those documents have a small size so its fine to keep a lot of versions from them. At least i want to keep (like you suggested) every version of those kind of documents which are not older than 7 days. Once they become older its fine to have less versions... e.g. default:999<age:7 default:1<age:14 default:1<age:21

on the other hand i have that awesome large outlook file. Here i would like to have default:1<age:7 default:1<age:30 default:1<age:180

any ideas?
Posts: 2
Joined: 12 Dec 2017

makman

Any updates? GUI? Appreciate this project and the work you put into it!
Posts: 3
Joined: 21 Mar 2018

Detox

ipconfig - This may very well work for me, however, I do not read German. Do you have an English version of the github page available?
My needs are much simpler. All I need is the ability to keep 1 archived file ( outlook pst; and 1 or 2 veracrypt containers) in addition to the current one from today's backup.

If you could provide an english version of that page, I hope to experiment with it.

All client PC's are windows 10. The all are backed up to a FreeNAS server.

Thanks for any help you can provide