LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 10-06-2014, 07:25 AM   #1
vjlxmi
Member
 
Registered: Aug 2014
Posts: 38

Rep: Reputation: Disabled
backup of files which will be replaced during rsync


hello,
i want to take a backup of those files which will be replaced during rsync.
i.e. newer or modified files in source will replace older files in destination, so i want to take the backup of the older files in the destination itself.
is it possible using rsync??
 
Old 10-06-2014, 07:38 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,185

Rep: Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673
probably this helps: http://webgnuru.com/linux/rsync_incremental.php
 
Old 10-06-2014, 04:08 PM   #3
cepheus11
Member
 
Registered: Nov 2010
Location: Germany
Distribution: Gentoo
Posts: 279

Rep: Reputation: 88
If you want to have access to the files in their older versions, rsnaphot or rdiff-backup can do it. Rsnapshot uses rsync internally.
 
Old 10-07-2014, 06:51 AM   #4
vjlxmi
Member
 
Registered: Aug 2014
Posts: 38

Original Poster
Rep: Reputation: Disabled
Incremental backup would take the backup of files which have been changed i.e. the newer files. But in my case I need to backup the files which will be over-written i.e. the older files.
 
Old 10-07-2014, 07:00 AM   #5
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,185

Rep: Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673
sorry guy, I do not understand. Those files will be lost if you did not make a backup before modification.
 
Old 10-07-2014, 07:12 AM   #6
vjlxmi
Member
 
Registered: Aug 2014
Posts: 38

Original Poster
Rep: Reputation: Disabled
yeah i know that once rsync is done the older data is lost. But before running the rsync command is there a way to just take backup of the files that will be changed?
 
Old 10-07-2014, 07:19 AM   #7
Drakeo
Senior Member
 
Registered: Jan 2008
Location: Urbana IL
Distribution: Slackware, Slacko,
Posts: 3,098
Blog Entries: 3

Rep: Reputation: 325Reputation: 325Reputation: 325Reputation: 325
ever looked at how "git" works. I mean your just adding to something then making a commit. then you will be able to go back to backup at will. you will be able to choose any of the times you put somthing in the git and commit.

and if you do branches and after a while you no longer need that branch you can delete it.
say branch-2013 and you will no longer need it get rid of it. you already have a brach-2014 started.
but that is a nice way of backing up and being able to look at changes.
 
Old 10-07-2014, 08:53 AM   #8
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,185

Rep: Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673
Quote:
Originally Posted by vjlxmi View Post
yeah i know that once rsync is done the older data is lost. But before running the rsync command is there a way to just take backup of the files that will be changed?
Sorry, still does not understand. rsync is used to make incremental backup. It means you will always save only the new/modified files, the old ones will not be backed up again. Every time you make a backup you will create it in a new directory, and all the earlier backups will remain intact.
 
Old 10-07-2014, 11:39 AM   #9
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,454

Rep: Reputation: 2052Reputation: 2052Reputation: 2052Reputation: 2052Reputation: 2052Reputation: 2052Reputation: 2052Reputation: 2052Reputation: 2052Reputation: 2052Reputation: 2052
Quote:
Originally Posted by pan64 View Post
Sorry, still does not understand. rsync is used to make incremental backup. It means you will always save only the new/modified files, the old ones will not be backed up again. Every time you make a backup you will create it in a new directory, and all the earlier backups will remain intact.
I think he wants to back up the old files on the destination before syncing them to the new files

In other words, he has machine A and machine B.
Machine A backs up to B using rsync
A backup is performed on Sunday
"filename.txt" on machine A is changed on Monday
Before he runs the rsync to sync up A and B, he wants to make a backup of "filename.txt" on B, so that when the backup is done, B has both copies of "filename.txt", the new one that matches A, and the old one from Sunday.

OP - look into the --link-dest flag in rsync. The basic idea is that you would perform a full backup from A to some dated directory on B, then the next time you did the backup, you would set --link-dest to the previous backup. Then when the backup is performed, any files that are UNCHANGED on the source, would simply be hard linked from the previous backup on the destination, while any files that are changed on the source are copied like normal. In the end, you have two full backups, one from the previous day and one from the current day, but it only takes up the hard drive space of one backup plus any files that changed between the two backups, since the unchanged files are hard-linked between the two.

Last edited by suicidaleggroll; 10-07-2014 at 11:40 AM.
 
Old 10-07-2014, 12:41 PM   #10
cepheus11
Member
 
Registered: Nov 2010
Location: Germany
Distribution: Gentoo
Posts: 279

Rep: Reputation: 88
Good description from suicidaleggroll, and rsnapshot is designed to automate exactly that. So if your concern is solely about disk usage with multiple backup time points, and you have many small files which do not change very often, this could be a solution.

It is not the right tool for often-changing large files like vm images, though.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] Problem rsync, deletes all files target after first succesfull backup KEES01NED Linux - Desktop 2 03-09-2014 06:34 AM
using rsync to backup files newbie0101 Linux - Software 1 01-08-2012 02:21 PM
rsync: only backup recently modified files hamish Linux - Software 3 09-20-2011 09:55 AM
LXer: How to use rsync to copy files, folders, and to backup in Linux LXer Syndicated Linux News 0 03-01-2011 12:00 AM
Dead Laptop RAM: How to backup files with Rsync? fragged Linux - Newbie 5 08-23-2009 01:43 PM


All times are GMT -5. The time now is 01:17 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration