Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
simple tar backup question
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
CaribbeanKnight
Apprentice
Apprentice


Joined: 27 Apr 2003
Posts: 240
Location: Earth -> Europe -> Belgium -> Diest

PostPosted: Fri Feb 20, 2004 2:12 am    Post subject: simple tar backup question Reply with quote

i'm doing a weekly backup of my gentoo system and i wanted to know if i'm doing anything wrong or something can be done better...
right now i use the following command to make a backup of my full disk to a mounted external disk:
Code:

tar cjvf /mnt/usbhd/gentoo-backup.tar.bz2 /* --exclude mnt

will i be safe this way? what about locked files (if they even exist on linux)? will everything like permissions and owner and stuff be restored fine if i restore with this: ?
Code:

tar xvjpf /mnt/usbhd/gentoo-backup.tar.bz2

thanks for all replies..!
Back to top
View user's profile Send private message
jmusits
Tux's lil' helper
Tux's lil' helper


Joined: 19 Jan 2004
Posts: 117
Location: New York

PostPosted: Fri Feb 20, 2004 2:34 am    Post subject: Reply with quote

Looks good to me, yes the file permissions and ownership will be preserved. That is what the p flag is for.

Jason
_________________
If you got the DO RE I got MI.

--Jerry Garcia "Run For The Roses"
Back to top
View user's profile Send private message
Genone
Retired Dev
Retired Dev


Joined: 14 Mar 2003
Posts: 9547
Location: beyond the rim

PostPosted: Fri Feb 20, 2004 12:15 pm    Post subject: Reply with quote

I'd also exclude /dev, /proc and /sys as those are virtual filesystems and "restoring" them doesn't make any sense.
Back to top
View user's profile Send private message
mirko_3
l33t
l33t


Joined: 02 Nov 2003
Posts: 605
Location: Birreria

PostPosted: Fri Feb 20, 2004 1:10 pm    Post subject: Reply with quote

Code:

mount /mnt/backup   #usually where we will backup stuff, so just mount it

find / -path '/tmp/*' -prune -o -path '/SAVEDSTUFF/*' -prune -o -path '/root/*' -prune -o -path '/var/tmp/portage/*' -prune -o -path '/mnt/*' -prune -o -path '/home/*' -prune -o -path '/data/' -prune -o -print | cpio -ov -Hnewc | bzip2 > $1.cpio.bz2

umount /mnt/backup

is what I use; I exclude /home as that is backed up nightly. In crontab I have:
Code:

0 4 * * sat /root/bin/full_backup.sh /mnt/backup/weekly_system

_________________
Non fa male! Non fa male!
Back to top
View user's profile Send private message
CaribbeanKnight
Apprentice
Apprentice


Joined: 27 Apr 2003
Posts: 240
Location: Earth -> Europe -> Belgium -> Diest

PostPosted: Mon Feb 23, 2004 8:39 am    Post subject: Reply with quote

been trying out some scripts, but it seems i'm always getting this same tar error somewhere along the way...
this is the command i use:
Code:

tar jcvpf /mnt/usbhd/zaterdag/gentoo.tar.bz2 * --exclude dev --exclude mnt --exclude proc --exclude sys


and this is the error:
Code:

.....
var/cache/samba/group_mapping.tdb
var/empty/
var/empty/.keep
var/spool/
var/spool/cron/
var/spool/cron/.keep
var/spool/cron/lastrun/
var/spool/cron/lastrun/.keep
var/spool/cron/lastrun/cron.daily
var/spool/cron/lastrun/cron.hourly
var/spool/cron/lastrun/cron.monthly
var/spool/cron/lastrun/cron.weekly
var/spool/cron/crontabs/
var/spool/cron/crontabs/.keep
var/spool/cups/
var/spool/cups/tmp/
var/spool/mail/
var/spool/mail/.keep
var/spool/.keep
var/spool/samba/
var/state/
var/state/.keep
tar: Error exit delayed from previous errors
MM-DBFACT root #


what does this mean..? i've found some posts saying you get this error when the disk is full, but this is not the case...
any help appreciated!
Back to top
View user's profile Send private message
mirko_3
l33t
l33t


Joined: 02 Nov 2003
Posts: 605
Location: Birreria

PostPosted: Mon Feb 23, 2004 1:27 pm    Post subject: Reply with quote

are you sure there's no error above that?
_________________
Non fa male! Non fa male!
Back to top
View user's profile Send private message
CaribbeanKnight
Apprentice
Apprentice


Joined: 27 Apr 2003
Posts: 240
Location: Earth -> Europe -> Belgium -> Diest

PostPosted: Tue Feb 24, 2004 4:01 am    Post subject: Reply with quote

nopes, that's all error message i get :?
Back to top
View user's profile Send private message
sapphirecat
Guru
Guru


Joined: 15 Jan 2003
Posts: 376

PostPosted: Tue Feb 24, 2004 3:59 pm    Post subject: Reply with quote

I bet the first line tar emits goes something like:
Code:
tar: stripping leading '/' from archive member names

And that's what's causing the "delayed error exit". You can check that by looking at the pathnames in the result of this command:
Code:
tar jtvf /mnt/usbhd/zaterdag/gentoo.tar.bz2 | less

_________________
Former Gentoo user; switched to Kubuntu 7.04 when I got sick of waiting on gcc. Chance of thread necro if you reply now approaching 100%...
Back to top
View user's profile Send private message
CaribbeanKnight
Apprentice
Apprentice


Joined: 27 Apr 2003
Posts: 240
Location: Earth -> Europe -> Belgium -> Diest

PostPosted: Sun Feb 29, 2004 9:55 pm    Post subject: Reply with quote

thanks!! you're right, there were some errors about the leading / stuff earlier on... but why doesn't tar quit immediately after such an error and quits randomly a while after..? this makes it hard to find out where the errors exactly happened...
Back to top
View user's profile Send private message
RedDawn
Guru
Guru


Joined: 22 Sep 2003
Posts: 368
Location: Los Angeles, California

PostPosted: Mon Mar 01, 2004 12:15 am    Post subject: I tried this!! Reply with quote

mirko_3 wrote:
Code:

#mount /mnt/backup   #usually where we will backup stuff, so just mount it

find / -path '/tmp/*' -prune -o -path '/mnt/*' -prune -o -path '/home/*' -prune -o -print | cpio -ov -Hnewc | bzip2 > $1.cpio.bz2

#umount /mnt/backup




Hey sorry.. i tried your backup script and stuff.
i edidted and did this what is up there!

One question since i commented out the mount and umount parts of the script where did the backup go when i ran the script?

Also how do i UNTAR or release the files back to the HD.. what command do i use?

Will my permissions be kept?

Thanks

EDIT: i found out that the compressed file is stored in wich ever folder i ran the script from... meaning its stored in /mnt/media/backup.. in my case!

Now the question is how do i uncompressed the whole backup into the disk with all my permisinons still the same!
Back to top
View user's profile Send private message
sapphirecat
Guru
Guru


Joined: 15 Jan 2003
Posts: 376

PostPosted: Mon Mar 01, 2004 3:52 pm    Post subject: Reply with quote

CaribbeanKnight wrote:
thanks!! you're right, there were some errors about the leading / stuff earlier on... but why doesn't tar quit immediately after such an error and quits randomly a while after..? this makes it hard to find out where the errors exactly happened...


In this case the error is a warning. tar is still putting everything into the archive it was asked to, just without the initial slash for items that began with it. It's to prevent the archive from destroying the system when it's unpacked. There's an option to turn this off (-P) if you really mean it.

When making backups, it's probably best to avoid mixing relative and absolute paths, to avoid making it a headache to reorganize when unpacking. I always use absolute paths so I don't have to care what directory I'm in when creating it.

FearPasion710 wrote:
Also how do i UNTAR or release the files back to the HD.. what command do i use?


Make another script:
Code:
bzip2 -d <$1.cpio.bz2 | cpio -iv -Hnewc

Cursory checking suggests it will maintain permissions.

I also suggest adding a few more directories to the backup script, as their contents are dynamically generated, and trying to restore them would be pointless at best:
Code:
find / -path '/dev/*' -prune -o -path '/proc/*' -prune -o -path '/sys/*' -prune -o -path '/tmp/*' -prune .....

_________________
Former Gentoo user; switched to Kubuntu 7.04 when I got sick of waiting on gcc. Chance of thread necro if you reply now approaching 100%...
Back to top
View user's profile Send private message
Hauser
l33t
l33t


Joined: 27 Dec 2003
Posts: 650
Location: 4-dimensional hyperplane

PostPosted: Mon Mar 01, 2004 5:05 pm    Post subject: Reply with quote

This thread may be of some help:
https://forums.gentoo.org/viewtopic.php?t=137093&highlight=hauser
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum