Duplicity – Incremental backups of a single file

To keep versions of a single file can be tricky. Specially if each version of the file big enough to cause troubles.

I have tried duplicity and it seems to fit very well.

Using debian 10, one can install it via:

apt-get install duplicity -y

duplicity --version
duplicity 0.7.18.2

Now, lets try it:

# create a txt file with the content

"Lorem ipsum dolor sit amet, consectetur adipiscing elit, 
sed do eiusmod tempor incididunt ut labore et dolore magna 
aliqua. Ut enim ad minim veniam, quis nostrud exercitation 
ullamco laboris nisi ut aliquip ex ea commodo consequat. 
Duis aute irure dolor in reprehenderit in voluptate velit 
esse cillum dolore eu fugiat nulla pariatur. Excepteur sint 
occaecat cupidatat non proident, sunt in culpa qui officia 
deserunt mollit anim id est laborum."

# check md5sum
md5sum text.txt
f2ee2b8db961879e2ee584dafd12d51e  text.txt

# and now, create a full backup
duplicity --no-encryption text.txt file://duplicity_backup

Local and Remote metadata are synchronized, no sync needed.
Last full backup date: none
No signatures found, switching to full backup.
--------------[ Backup Statistics ]--------------
StartTime 1601031648.90 (Fri Sep 25 13:00:48 2020)
EndTime 1601031648.91 (Fri Sep 25 13:00:48 2020)
ElapsedTime 0.00 (0.00 seconds)
SourceFiles 1
SourceFileSize 455 (455 bytes)
NewFiles 1
NewFileSize 455 (455 bytes)
DeletedFiles 0
ChangedFiles 0
ChangedFileSize 0 (0 bytes)
ChangedDeltaSize 0 (0 bytes)
DeltaEntries 1
RawDeltaSize 455 (455 bytes)
TotalDestinationSizeChange 386 (386 bytes)
Errors 0
-------------------------------------------------

The first full backup has been created inside directory duplicity_backup. Lets add more text to it:

"Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation
ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit
esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officia
deserunt mollit anim id est laborum."

I have a dream today!

I have a dream that one day every valley shall be exalted, 
and every hill and mountain shall be made low, the rough 
places will be made plain, and the crooked places will be 
made straight; "and the glory of the Lord shall be revealed 
and all flesh shall see it together."
Martin Luther King, Jr.

# check md5sum
md5sum text.txt
5f014ce71dcd07794984a7837e67c8a9  text.txt

Now, lets do another run of duplicity:

duplicity --no-encryption text.txt file://duplicity_backup

Local and Remote metadata are synchronized, no sync needed.
Last full backup date: Fri Sep 25 13:00:48 2020
--------------[ Backup Statistics ]--------------
StartTime 1601032002.25 (Fri Sep 25 13:06:42 2020)
EndTime 1601032002.26 (Fri Sep 25 13:06:42 2020)
ElapsedTime 0.00 (0.00 seconds)
SourceFiles 1
SourceFileSize 779 (779 bytes)
NewFiles 0
NewFileSize 0 (0 bytes)
DeletedFiles 0
ChangedFiles 1
ChangedFileSize 779 (779 bytes)
ChangedDeltaSize 0 (0 bytes)
DeltaEntries 1
RawDeltaSize 787 (787 bytes)
TotalDestinationSizeChange 560 (560 bytes)
Errors 0
-------------------------------------------------

# The field ChangedFiles now marks 1

It is possible to list files that duplicity worked on:

duplicity list-current-files --no-encryption file://duplicity_backup

Local and Remote metadata are synchronized, no sync needed.
Last full backup date: Fri Sep 25 13:00:48 2020
Fri Sep 25 13:05:46 2020 .

To restore the first version:

duplicity restore -t 7M --no-encryption file://duplicity_backup restored_text.txt

Local and Remote metadata are synchronized, no sync needed.
Last full backup date: Fri Sep 25 13:00:48 2020

# the 7M flag is asking for a version that is 7 minutes old. 

# checking md5sum 

md5sum restored_text.txt 
f2ee2b8db961879e2ee584dafd12d51e  restored_text.txt
# and the first version
f2ee2b8db961879e2ee584dafd12d51e  text.txt

cat restored_text.txt
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, 
sed do eiusmod tempor incididunt ut labore et dolore magna 
aliqua. Ut enim ad minim veniam, quis nostrud exercitation 
ullamco laboris nisi ut aliquip ex ea commodo consequat. 
Duis aute irure dolor in reprehenderit in voluptate velit 
esse cillum dolore eu fugiat nulla pariatur. Excepteur sint 
occaecat cupidatat non proident, sunt in culpa qui officia 
deserunt mollit anim id est laborum."




References

Duplicity – http://duplicity.nongnu.org/index.html

Duplicity manual – http://duplicity.nongnu.org/vers7/duplicity.1.html

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s