View previous topic :: View next topic |
Author |
Message |
CaribbeanKnight Apprentice
Joined: 27 Apr 2003 Posts: 240 Location: Earth -> Europe -> Belgium -> Diest
|
Posted: Fri Feb 20, 2004 2:12 am Post subject: simple tar backup question |
|
|
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 |
|
|
jmusits Tux's lil' helper
Joined: 19 Jan 2004 Posts: 117 Location: New York
|
Posted: Fri Feb 20, 2004 2:34 am Post subject: |
|
|
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 |
|
|
Genone Retired Dev
Joined: 14 Mar 2003 Posts: 9547 Location: beyond the rim
|
Posted: Fri Feb 20, 2004 12:15 pm Post subject: |
|
|
I'd also exclude /dev, /proc and /sys as those are virtual filesystems and "restoring" them doesn't make any sense. |
|
Back to top |
|
|
mirko_3 l33t
Joined: 02 Nov 2003 Posts: 605 Location: Birreria
|
Posted: Fri Feb 20, 2004 1:10 pm Post subject: |
|
|
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 |
|
|
CaribbeanKnight Apprentice
Joined: 27 Apr 2003 Posts: 240 Location: Earth -> Europe -> Belgium -> Diest
|
Posted: Mon Feb 23, 2004 8:39 am Post subject: |
|
|
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 |
|
|
mirko_3 l33t
Joined: 02 Nov 2003 Posts: 605 Location: Birreria
|
Posted: Mon Feb 23, 2004 1:27 pm Post subject: |
|
|
are you sure there's no error above that? _________________ Non fa male! Non fa male! |
|
Back to top |
|
|
CaribbeanKnight Apprentice
Joined: 27 Apr 2003 Posts: 240 Location: Earth -> Europe -> Belgium -> Diest
|
Posted: Tue Feb 24, 2004 4:01 am Post subject: |
|
|
nopes, that's all error message i get |
|
Back to top |
|
|
sapphirecat Guru
Joined: 15 Jan 2003 Posts: 376
|
Posted: Tue Feb 24, 2004 3:59 pm Post subject: |
|
|
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 |
|
|
CaribbeanKnight Apprentice
Joined: 27 Apr 2003 Posts: 240 Location: Earth -> Europe -> Belgium -> Diest
|
Posted: Sun Feb 29, 2004 9:55 pm Post subject: |
|
|
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 |
|
|
RedDawn Guru
Joined: 22 Sep 2003 Posts: 368 Location: Los Angeles, California
|
Posted: Mon Mar 01, 2004 12:15 am Post subject: I tried this!! |
|
|
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 |
|
|
sapphirecat Guru
Joined: 15 Jan 2003 Posts: 376
|
Posted: Mon Mar 01, 2004 3:52 pm Post subject: |
|
|
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 |
|
|
Hauser l33t
Joined: 27 Dec 2003 Posts: 650 Location: 4-dimensional hyperplane
|
|
Back to top |
|
|
|