LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-24-2012, 12:53 PM   #1
TrainingPeaks
LQ Newbie
 
Registered: Jul 2012
Posts: 2

Rep: Reputation: Disabled
Rsync + hard links backup strategy questions


I'm using several of Amazon's EC2 linux instances for a Deploy & Live MongoDB environment, and have been working on my backup strategy for a few days.

I've narrowed it down to using LVM snapshots to obtain a consistent data volume which I rsync to my backup server.

I do this on an hourly basis from the backup server itself, using the following script:

Code:
#!/bin/bash

# ... some config stuff before this ...

cd /backup

#Rotate all existing backups back 1 hour, and entirely delete the oldest one.
rm -fr 24h
for i in {23..1}
do
    mv ${i}h $(($i + 1))h
done

#Make a copy of the current backup into the 1h bucket, using hard links to avoid duplicating data.
cp -la current 1h

# Rsync 
echo "Created on `date`" | tee -a /backup/current/DATETIME
rsync -e "ssh -i ***.pem" --verbose --recursive --times --perms --links --delete ***@***:~/backup/ /backup/current
Then, once a day at midnight, I run the following script:

Code:
#!/bin/bash

mv 6d 7d
mv 5d 6d
mv 4d 5d
mv 3d 4d
mv 2d 3d
mv 1d 2d
mv 24h 1d
rm -fr 24h/*
The idea being to have daily backups for a weekly as well as hourly backups for a day.
Finally, I run the following script once a week on a Saturday morning:

Code:
#!/bin/bash

cd /backup
mv current weekly
rm -fr current/*
The idea being to have a weekly backup, and by deleting my /backup/current folder to force rsync to do a completely fresh copy once a week to ensure consistency.

Any input on this backup strategy?
Any input on my scripts? Are they doing what I expect them to do?
Just looking for general feedback....

Thanks!
 
Old 07-25-2012, 01:31 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,930

Rep: Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321
I would try the option --link-dest probably you can save a lot of time and space.
 
Old 07-25-2012, 09:07 AM   #3
TrainingPeaks
LQ Newbie
 
Registered: Jul 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thanks! But

Code:
cp -la current 1h
My understanding is, using hard-link copy like above achieves the same space savings as link-dest (which is just a hard-link copy command, in my understanding). Further, my doing the hard-link copy myself, I have more control over how to store/keep/rotate the backups.
 
Old 07-25-2012, 10:59 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,930

Rep: Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321
No, I think you misunderstood. --link-dest will work file by file: if file changed it will be copied if file was not changed since the last backup it will be linked instead (that will save the time of copy and space too). You can give several --link-dest options to use several backups. For example: you will get every time a new backup, but the files not changed since the first backup will be stored only once.
Also you can try to read rsync forums there are a lot of discussion about how to use rsync for incremental backups and similar tasks, you may find usable ideas.
 
  


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
Rsync: backups and hard links JosephS Linux - Software 3 09-17-2012 06:03 AM
[SOLVED] rsync --link-dest not creating hard links on external usb drive quasi3 Linux - General 4 08-26-2009 10:11 AM
backup strategy for rsync songeek Linux - Server 2 07-05-2007 09:30 PM
Rsync - Backup vs. Hard Links Only hazmatt20 Linux - Software 2 08-18-2006 07:32 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:16 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
Open Source Consulting | Domain Registration