[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: tar on flash drive



On Sun, Jan 18, 2009 at 11:25:01PM -0800, postid@BasicISP.net wrote:
> I have a damaged system on my laptop and am trying to salvage data,
> then will likely install a new system (etch or lenny, was sarge). I'd
> like to save the home folder and a few useful files gleaned from the
> etc folder, keeping permissions. I'll use a live cd to do the salvage
> work (lenny live, knoppix, knoppix STD or slax -- I have all
> available) and write to a 4GB usb flash drive. 
> 
> Is this the proper syntax? I believe the -c must be first and the -f
> last.
> 
> tar -chpvf /mnt/sda1/homebackup.tar /mnt/hda2/home
> 
> -c is create a new archive -h is retain symlinks but not the files to
> which they point -p is preserve permissions -v is verbose -f is
> indicating that the destination file name follows immediately after
> 
> Is -h the best way to handle symlinks?  Is having the destination file
> on a flash drive a potential problem? 
 
> Your input is appreciated. Please cc me as I am not currently
> subcribed to the list.

[done]

For what it does, yes your tar options look fine.  Are you sure that you
want to lose other stuff such as /etc, your package choices, etc?

I'll attach the script I use.  I alter it for each box (since each is
slightly diffferent).  The script I'm attaching is what I run on the box
from which I'm sending this email (plot).  It uses a list of directories
to backup and a list to exclude.  I'll include those files too.

Doug.


#!/bin/bash
### special to hostname plot
# Backup to /var/local/backup/plot

# backing up directories listed in /usr/local/etc/backup/list
# and excluding those in /usr/local/etc/backup/excludelist
/bin/echo -e "System Backup"
/bin/echo -e "=============\n"
/bin/echo -e "First: ensure users have saved essential stuff to ~/essential_backup,"
/bin/echo -e "either as sym-links or actual files; backup will dump links as files."
/bin/echo -e "Examples may be: exporting bookmarks list, special docs, etc."
/bin/echo -e "Backup will then save those to a separate file before"
/bin/echo -e "running the main backup program.\n"
/bin/echo -e "\nBackup files will be in /var/local/backup/plot/"
/bin/echo -e "and will be done in order of priority to restoring the system."
/bin/echo -e "These can then be copied to media-of-choice.\a\n"
/bin/echo -e "\nBackup takes around 10 minutes.\n"
#read -p "Press <enter> when ready to continue backup"

/bin/echo -e "\nSaving grub menu.lst..."
/bin/cp -af /boot/grub/menu.lst /var/local/backup/plot
/bin/echo -e "Done.\n"

/bin/echo -e "\nSaving necessary /etc/files plain text..."

mkdir -m 0750 /var/local/backup/plot/etc
chown root.adm /var/local/backup/plot/etc

/bin/cp -af /etc/fstab /var/local/backup/plot/etc
/bin/cp -af /etc/modules /var/local/backup/plot/etc
/bin/cp -af /etc/hosts /var/local/backup/plot/etc
/bin/cp -af /etc/hosts.allow /var/local/backup/plot/etc
/bin/cp -af /etc/hosts.deny /var/local/backup/plot/etc
/bin/cp -af /etc/inittab /var/local/backup/plot/etc
/bin/cp -af /etc/network/interfaces /var/local/backup/plot/etc
/bin/cp -af /etc/hostname /var/local/backup/plot/etc
/bin/cp -af /etc/modutils/ /var/local/backup/plot/etc/
/bin/rm -rf /var/local/backup/plot/etc/modutils/arch
/bin/cp -af /etc/modprobe.d/ /var/local/backup/plot/etc/
/bin/cp -af /etc/resolv.conf /var/local/backup/plot/etc
/bin/cp -af /etc/ppp/	/var/local/backup/plot/etc/
/bin/cp -af /etc/chatscripts/ /var/local/backup/plot/etc/

/bin/echo -e "Done.\n"

/bin/echo -e "\nSaving the partition table and disk usage information..."
/sbin/fdisk -lu /dev/hda > /var/local/backup/plot/hda_partitions
/sbin/sfdisk -d /dev/hda > /var/local/backup/plot/hda_sfdisk.out
/sbin/fdisk -lu /dev/hdc > /var/local/backup/plot/hdc_partitions
/sbin/sfdisk -d /dev/hdc > /var/local/backup/plot/hdc_sfdisk.out
du -c --si --max-depth=1 /* > /var/local/backup/plot/dusummary 2>/dev/null
df --si > /var/local/backup/plot/dfsummary
/bin/echo -e "Done.\n"

/bin/echo -e "\nSaving package selection..."
dpkg --get-selections > /var/local/backup/plot/inst_deb.sel
aptitude search '~i!~M' > /var/local/backup/plot/apt_inst.sel
/bin/echo -e "Done.\n"


/bin/echo -e "\nBacking up /root/service/ to /var/local/backup/plot"
/bin/cp -af /root/service/  /var/local/backup/plot/

/bin/echo -e "\nSaving etc.tgz.bak" 
/bin/cp -af /var/local/backup/plot/etc.tgz /var/local/backup/plot/etc.tgz.bak
/bin/echo -e "Backing up /etc/ to /var/local/backup/plot/etc.tgz"
#/bin/tar -czf /var/local/backup/plot/etc.tgz /etc/ 
/bin/tar -c /etc/ | gzip --best --rsyncable > /var/local/backup/plot/etc.tgz 

/bin/echo -e "Done."
/bin/echo "Removing saved etc.tgz.bak"
/bin/rm -f /var/local/backup/plot/etc.tgz.bak
/bin/echo -e "Done.\n"

/bin/echo -e "\nSaving es_bk.tgz.bak"
/bin/cp -af /var/local/backup/plot/es_bk.tgz /var/local/backup/plot/es_bk.tgz.bak
/bin/echo -e "Backing up /var/local/essential_backup/ >"
/bin/echo -e "                            /var/local/backup/plot/es_bk.tgz"

#/bin/tar -czhPf /var/local/backup/plot/es_bk.tgz /var/local/essential_backup/
/bin/tar -chP /var/local/essential_backup/ | gzip --best --rsyncable > /var/local/backup/plot/es_bk.tgz 
# c=create, -h=don't dump symlinks, but files pointed to
# P=ablsolute path name so they go back exactly where they belong
/bin/echo -e "Done"
/bin/echo "Removing saved es_bk.tgz.bak"
/bin/rm -f /var/local/backup/plot/es_bk.tgz.bak
/bin/echo -e "Done.\n"

#/bin/echo "Saving backup.tgz.bak"
#/bin/cp -af /var/local/backup/plot/backup.tgz /var/local/backup/plot/backup.tgz.bak
#/bin/echo -e "Backing-up complete system: > /var/local/backup/plot/backup.tgz"
#/bin/tar -czf /var/local/backup/plot/backup.tgz -T /usr/local/etc/backup/backuplist -X /usr/local/etc/backup/excludelist
#/bin/echo "Removing saved backup.tgz.bak"
#/bin/rm -f /var/local/backup/plot/backup.tgz.bak
#/bin/echo "Done."

/bin/echo -e "\n\nBacking-up complete system: > "
/bin/echo -e "                          /var/local/backup/plot/backup.tgz.XX"
/bin/rm -f /var/local/backup/plot/backup.t*
#/bin/tar -cz -T /usr/local/etc/backup/backuplist -X /usr/local/etc/backup/excludelist | split -b 600m - /var/local/backup/plot/backup.tgz. 
/bin/tar -c -T /usr/local/etc/backup/backuplist -X /usr/local/etc/backup/excludelist | gzip --best --rsyncable |split -b 500m - /var/local/backup/plot/backup.tgz. 
/bin/echo -e "Done.\n"

#/bin/echo -e "\nSaving uldl.tgz.bak"
#/bin/cp -af /var/local/backup/plot/uldl.tgz /var/local/backup/plot/uldl.tgz.bak
#/bin/echo -e  "Backing up /home/dtutty/uldl > /var/local/backup/plot/uldl.tgz"
#/bin/tar -czf /var/local/backup/plot/uldl.tgz /home/dtutty/uldl/
#/bin/tar -c /home/dtutty/uldl/ | gzip --best --rsyncable > /var/local/backup/plot/uldl.tgz 
#/bin/echo "Removing saved uldl.tgz.bak"
#/bin/rm -f /var/local/backup/plot/uldl.tgz.bak
#/bin/echo -e "Done.\n"

/bin/echo -e "\nChanging oweners and permissions of /var/local/backup/plot"
/bin/chown -R root.adm /var/local/backup/plot/*
/bin/chmod -R o-rwx /var/local/backup/plot/*
/bin/chmod -R g+rw /var/local/backup/plot/*
/bin/echo -e "Done.\n"

/bin/sync
/bin/echo -e "\a\nBackup finished.\n"

/bin/echo -e "Remember to copy to appropriate media.\n"

# vim: tw=0 :

/etc/
/usr/local/
/root/
/var/local/
/home/
/var/local/backup
/var/local/unbackedup
/home/dtutty/uldl
/root/uldl
/home/media


Reply to: