LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-24-2023, 09:58 AM   #1
john99
Member
 
Registered: Mar 2007
Posts: 46

Rep: Reputation: 15
adding date-string to filenames (deduplicating)


Hi all

in the past I copied files and folders to a backup-folder and added the date of the backup manually to that folder.

Now/today it's time for deduplication


The simplest way I could imagine is a script that would add date and time to a file, cor the case there are serveral version available.

That script should check/look in subfolders as well (because there are many backup-filders).

If there are identical files, only one version should be kept.

Questions:
1.
Is this a good idea?

2.
How would such s script look like?



Thank's a lot in advance for every feedback!

John


PS
I am working with Debian/Ubuntu/Mint
 
Old 11-24-2023, 10:01 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,041

Rep: Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348
rsync can do that alone, do not need to write any script, just use incremental backups.
 
1 members found this post helpful.
Old 11-24-2023, 06:14 PM   #3
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
In the case of nested directories that may contain duplicates you would need to start at the top level and for each file check if there is a matching file in the next level down.
If there then verify if they match or not -- file size and checksums are both good attributes to verify match.
If they don't match then rename the one in the level below, if they match then delete the one below.
Repeat for each file and each subdirectory.

As noted, rsync can be used similarly with the delete option, but may not be precise for different versions of files with the same name -- especially if you wish to retain more than the latest version.

Once you have cleaned up the existing structure then rsync would do well for incremental backups, with the caveat that only the latest version backed up would be retained.
 
Old 11-24-2023, 06:20 PM   #4
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,346

Rep: Reputation: 552Reputation: 552Reputation: 552Reputation: 552Reputation: 552Reputation: 552
Quote:
Originally Posted by computersavvy View Post
Once you have cleaned up the existing structure then rsync would do well for incremental backups, with the caveat that only the latest version backed up would be retained.
If you want to retain more than the latest version you can use generations of incremental backup and keep rsync cycling through the generations.
 
Old 11-25-2023, 12:22 AM   #5
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,832

Rep: Reputation: 1219Reputation: 1219Reputation: 1219Reputation: 1219Reputation: 1219Reputation: 1219Reputation: 1219Reputation: 1219Reputation: 1219
Existing files you can examine and eventually hard-link with
rdfind
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Backup with these DeDuplicating Encryption Tools LXer Syndicated Linux News 0 06-28-2015 07:33 AM
LXer: Attic – Deduplicating backup program LXer Syndicated Linux News 0 01-25-2015 04:33 PM
[Bash] Rename filenames with corresponding filenames Power2All Linux - Software 4 12-02-2009 04:15 AM
Date comparison with 'string date having slashes and time zone' in Bash only TariqYousaf Programming 2 10-08-2009 07:37 AM
Bash Script - adding file modification date to end of filenames in directory themonkman Programming 2 09-01-2009 11:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration