[1] http://ubuntuforums.org/archive/index.php/t-194938.html
[2] http://www.cyberciti.biz/faq/linux-unix-extracting-specific-files/ --- Untar part of tar ball
EXCLUDE SOME FOLDERS WHEN DOING TAR BALL
--------------------------------------------
[root@localhost media]# tar -cvzpP --file=/mnt/200GSys/backuproot.tar.gz --exclude={/mnt/*,/boot/*,/home/*,/opt/*} /
INCLUDE MULTIPLE FOLDERS WHEN DOING TAR BALL
----------------------------------------------
tar -cvzpP --file=/home/q.yang/$NAME /home/q.yang/CodeSourcery /home/q.yang/devel /home/q.yang/Documents /home/q.yang/Download /home/q.yang/EclipseCDT /home/q.yang/JavaDev /home/q.yang/lpc3250
SAMPLE BACK UP SHELL
-----------------------------
[q.yang@localhost ~]$ cat tar_quentin_home_data.sh
NAME='Linux_Quentin_Home_bkup'_$(date +%g%m%d%H).tar.gz
if [ -f "$NAME" ]
then
echo "File $NAME exist already."
return
fi
touch $NAME
#find . -name "*.java" -mtime -$TimeRange -exec tar -uvf $NAME {} \;
#echo "source files of last $TimeRange days"
#find . -name "*.java" -mtime -$TimeRange -exec ls -all -ct {} \;
echo "tar -cvzpP --file=/home/q.yang/$NAME /home/q.yang/CodeSourcery /home/q.yang/devel /home/q.yang/Documents /home/q.yang/Download /home/q.yang/EclipseCDT /home/q.yang/JavaDev /home/q.yang/lpc3250 /home/q.yang/root_user_cmd_list.txt /home/q.yang/rpmbuild /home/q.yang/tar_quentin_home_data.sh /home/q.yang/.bash_profile /home/q.yang/.bash_history /home/q.yang/.bash_logout"
tar -cvzpP --file=/home/q.yang/$NAME /home/q.yang/CodeSourcery /home/q.yang/devel /home/q.yang/Documents /home/q.yang/Download /home/q.yang/EclipseCDT /home/q.yang/JavaDev /home/q.yang/lpc3250 /home/q.yang/root_user_cmd_list.txt /home/q.yang/rpmbuild /home/q.yang/tar_quentin_home_data.sh /home/q.yang/.bash_profile /home/q.yang/.bash_history /home/q.yang/.bash_logout
SAMPLE OF UNTAR TAR BALL
-----------------------------
[root@localhost q.yang]# cat /home/l.lu/untar_luke_home_usr_data.sh
#NAME='Linux_Luke_Home_Data__bkup'_$(date +%g%m%d%H).tar.gz
NAME=$1
OUTDIR=$2
if [ -f "$NAME" ]
then
echo "About to untar $NAME"
else
echo "File '$NAME' does not exist."
echo ""
echo "Sample running this shell 'untar_luke_home_usr_data.sh':"
echo ""
echo ". untar_luke_home_usr_data.sh Linux_Luke_Home_Data__bkup_$(date +%g%m%d%H).tar.gz"
echo ""
return
fi
mkdir $OUTDIR
echo "tar -xzvf $NAME -C $OUTDIR/"
tar -xzvf $NAME -C $OUTDIR/
ISSUES USING SYSTEM TAR COMMAND
-------------------------------------------------
When tar -xzvf on another Linux machine. I had a many complains of not able to change ownership.
This is one discussion about this issue on 'stackoverflow'.
"how to keep file ownership while using tar"
http://stackoverflow.com/questions/17273798/how-to-keep-file-ownership-while-using-tar
Someone recommended that using pure perl rather than system command to do archive and restore.
Below is a good link of how to use perl to do advance archive and restore.
http://perldoc.perl.org/Archive/Tar.html
Tuesday, February 22, 2011
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment