LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-23-2009, 11:29 AM   #1
kkempter
Member
 
Registered: Dec 2002
Posts: 187

Rep: Reputation: 30
backup/recovery with rsync


Hi all;

I've got a new dell laptop I'm trying to setup. Most everything is working
well but I cannot get dual monitor support working. There's a local Linux
install-fest this weekend near me and I plan to attend seeking some help. *
However, I use this laptop as my main work computer and I cannot afford for it
to be down, so just in case something we do at install-fest breaks my system
(in fact I had early issue with the nvidia drivers causing me to only see a
blank screen) I want to be able to restore properly.

Here's what I've done so far:

I have a filesystem "/stage" where I'm staging an rsync backup.

I have a script that reads a list of directories and does an rsync. *I've
listed all root level (/) directories in this list except for stage, dev and
sys since dev and sys are generated at boot time and stage is where I'm
pushing the backups to. So, my backup scripts look like this:


dirlist:
==========
bin * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
boot * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
docs * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
download
etc
home
lib
lib64
lost+found
media
mnt
opt
root
sbin
selinux
srv
tmp
usr
var


rsync_backup.sh:
==================
#!/bin/bash

for I in `cat dirlist`
do
* * * * echo "[$I]"
* * * * echo "=========="
* * * * rsync -avXA --delete /${I} /stage/backup/rsync
done


rsync_restore.sh:
==================
#!/bin/bash

for I in `cat dirlist`
do
* * * * echo "[$I]"
* * * * echo "=========="
* * * * rsync -avXA --delete /stage/backup/rsync/${I} /
done





Here's my questions. * Is this going to be reliable , i.e. if I have to
restore will it accurately restore the entire system ?


When I run the backup script I see IO errors like this:

home/kkempter/.xsession-errors * * * * * * * * * * * * * * * * * * * * * * * * * * *
IO error encountered -- skipping file deletion * * * * * * * * * * * * * * * * * * *

rsync error: some files/attrs were not transferred (see previous errors) (code
23) at main.c(1040) [sender=3.0.4] * * * * * * * * * * * * * * * * * * * * * * * * * * * *

rsync error: some files/attrs were not transferred (see previous errors) (code
23) at main.c(1040) [sender=3.0.4]


I also see SE Linux warnings like this:

Summary
SELinux is preventing rsync from creating a file with a context of security_t
on a filesystem.

Detailed Description
SELinux is preventing rsync from creating a file with a context of security_t
on a filesystem.
Usually this happens when you ask the cp command to maintain the context of a
file when copying between
file systems, "cp -a" for example. Not all file contexts should be maintained
between the file systems.
For example, a read-only file type like iso9660_t should not be placed on a r/w
system. "cp -P" might be a better solution,
as this will adopt the default file context for the destination.

Allowing Access
Use a command like "cp -P" to preserve all permissions except SELinux context.

Additional Information
Source Context: *system_ubject_r:security_t:s0
Target Context: *system_ubject_r:fs_t:s0
Target Objects: *.index.6k5mIl [ filesystem ]
Source: *rsync
Source Path: */usr/bin/rsync
Port: *<Unknown>
Host: *Issac.consistentstate.com
Source RPM Packages: *rsync-3.0.4-0.fc10
Target RPM Packages: *Policy RPM: *selinux-policy-3.5.13-38.fc10
Selinux Enabled: *True
Policy Type: *targeted
MLS Enabled: *True
Enforcing Mode: *Enforcing
Plugin Name: *filesystem_associate
Host Name: *Issac.consistentstate.com
Platform: *Linux Issac.consistentstate.com 2.6.27.7-134.fc10.x86_64 #1 SMP Mon
Dec 1 22:21:35 EST 2008 x86_64 x86_64
Alert Count: *1
First Seen: *Fri 23 Jan 2009 09:12:23 AM MST
Last Seen: *Fri 23 Jan 2009 09:12:23 AM MST
Local ID: *77df5603-8c05-4884-ac35-19a5cab2070a
Line Numbers: *
Raw Audit Messages :
node=Issac.consistentstate.com type=AVC msg=audit(1232727143.337:1347): avc:
denied { associate } for pid=8099 comm="rsync" name=".index.6k5mIl" dev=sdb1
ino=4825112 scontext=system_ubject_r:security_t:s0
tcontext=system_ubject_r:fs_t:s0 tclass=filesystem
node=Issac.consistentstate.com type=SYSCALL msg=audit(1232727143.337:1347):
arch=c000003e syscall=189 success=no exit=-13 a0=7fff5f0c8610 a1=17055e0
a2=17055c0 a3=20 items=0 ppid=8098 pid=8099 auid=500 uid=0 gid=0 euid=0 suid=0
fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts1 ses=1 comm="rsync" exe="/usr/bin/rsync"
subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=(null)




Thoughts ?

Thanks in advance
 
Old 01-23-2009, 01:44 PM   #2
kilgoretrout
Senior Member
 
Registered: Oct 2003
Posts: 3,001

Rep: Reputation: 393Reputation: 393Reputation: 393Reputation: 393
Use a livecd and just tar up the partition you want to backup. Slax is an excellent tool to use for this purpose as it automatically mounts all partitions and boots to the root user by default:

http://www.slax.org/

For example, suppose your installed distro is on sda1 and you want to backup that partition to single compressed tar archive on sda2. Boot up your livecd and open a console. Determine the mount points of sda1 and sda2 by running:

# mount

Which will list everything mounted and the mount points. IIRC slax mounts partitions on /media/<device file> so the mount points in the example would be /media/sda1 and /media/sda2. cd to the mount point of the partition you want to back up, /media/sda1:

# cd /media/sda1

and run:

# tar -czvf /media/sda2/backup.tar.gz .

That will fully backup everything in sda1 to a compressed archive in sda2 named backup.tar.gz. Note the last "." in the command is no typo; it's an essential part of the command and is what directs tar to backup everything in the current directory. If you don't have that period, the command won't run.

Restoring is just as easy. Boot with your slax livecd, open a console and run:

# cd /media/sda1
# tar -xvzf /media/sda2/backup.tar.gz

And tar will uncompress and open backup.tar.gz in the current directory, sda1's mount point, which will fully restore the sda1 partition.

I've been doing my backups like this for years without any trouble. Using a livecd avoids many problems. And no matter what tool you use for your full system backup, remember to run that as root. There are many files on any standard linux installation that are only readable by root and if you try to copy that file as an ordinary user, you'll just get error messages.
 
  


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
LXer: How to backup MySQL and recovery Using Zmanda Recovery Manager LXer Syndicated Linux News 0 09-10-2008 04:30 AM
rsync backup songeek Solaris / OpenSolaris 1 07-05-2007 07:01 AM
Using RSync to backup a secondary off-site backup server pezdspencer Linux - Software 4 06-29-2007 03:40 PM
Using rsync to backup data. Best way to backup folders? Micro420 Linux - General 2 11-23-2006 01:13 AM
rsync as backup? ziggie216 Linux - Software 3 03-13-2005 02:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:53 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