[Mysolved] Backup with checksum comparison.

Discuss and share scripts and script files...
Post Reply
eil
Posts: 1621
Joined: 13 Jan 2011 19:44

[Mysolved] Backup with checksum comparison.

Post by eil »

i hope i did search properly, 'cause i didn't find some script to be close to my needs(which actually made me surpriced). so i hope smb can help me with at least parts of code.

i'm in need of script that backups list of items to target folder, while checking if there are collisions. in case of collision files need to be compared by checksum. same checksum = no action/skip file, otherwise rename existing with adding modified date suffix to name and copy new.
eventually it will look like: file.ext, file-<modified_date>.ext, file-<modified_date>.ext, etc. so i need to have some way of cheking "suffixed files overload". if number of suffixed files(with same name but different suffixes) exceeds the number set in variable - delete the oldest suffixed file.
Last edited by eil on 10 Oct 2019 19:03, edited 1 time in total.
Win 7 SP1 x64 100% 1366x768

highend
Posts: 13317
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: [Request] Backup with checksum comparison.

Post by highend »

Then show the code you've already done and describe where exactly you're having a problem?
One of my scripts helped you out? Please donate via Paypal

eil
Posts: 1621
Joined: 13 Jan 2011 19:44

Re: [Request] Backup with checksum comparison.

Post by eil »

you understood it wrong, i ment if maybe people know other scripts that have parts with similar actions, so i could research them to understand how to make mine. have no code for now.
Win 7 SP1 x64 100% 1366x768

highend
Posts: 13317
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: [Request] Backup with checksum comparison.

Post by highend »

Sorry but I don't get the real problem. It's a loop over <some> files, maybe from the current folder.
A simple if/else if the file already exists in the destination folder
If it does not exist, copy it
If it does exist, compare checksums of both and depending on if they match
They match: Do nothing
They don't:
Do the renaming of the original file
Test how many files in the destination folder exists, that have the same base + the modified date part
Count them
If they are over the limit, sort them descending, delete the last one(s)
Copy the file...

The only "difficult" part (for a novice) is the "get files with the same base" because it should be done with a regex...
One of my scripts helped you out? Please donate via Paypal

eil
Posts: 1621
Joined: 13 Jan 2011 19:44

Re: [Mysolved] Backup with checksum comparison.

Post by eil »

after whole DAY of being noob but figuring out how to do this "simple", finally made it. so i thank me very much, especially for solving it without regex. :maf:
Win 7 SP1 x64 100% 1366x768

highend
Posts: 13317
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: [Mysolved] Backup with checksum comparison.

Post by highend »

so, share the code?
One of my scripts helped you out? Please donate via Paypal

Post Reply