macsplex.com 로그인

검색

조회 수 166 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 게시글 수정 내역 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 게시글 수정 내역 댓글로 가기 인쇄
Extra Form
펌글(http://blog.naver.com/insanary/140018070646)



이번에 HDD를 싹 밀고 OS를 재설치하는 과정에서 이 젠투리눅스를 하도 재설치를 많이 하게되서



이번기회에 백업을 해버릴려고 알아보는 중에 젠투 포럼에서 괜찮은 스크립트를 찾게 되었습니다.



올리 글 내용을보니 IBM놋북에서 3.5기가 가량을 백업하니 800메가가 되었고 약 50분이 걸렸다길래 소개합니다.



젠투를 설치하시는 분들은 이 스크립트로 베이스만 설치하고 백업하시면 시간절약이 엄청나게 될것입니다. ^



저는 X윈도우까지 설치한뒤에 백업을 했습니다. ㅎㅎ







원본 글 링크입니다.



http://forums.gentoo.org/viewtopic-t-312817-highlight-backup.html



백업 Code:

#!/bin/bash

# Backup script for Gentoo Linux

# Copyright Reto Glauser aka Blinkeye

# Distributed under the terms of the GNU General Public License v2

# Mailto: stage4 at blinkeye dot ch

# Forum post: http://forums.gentoo.org/viewtopic-t-312817.html

# Date: 20.04.2005



version=v1.4.2



# these are the commands we actually need for the backup

command_list="echo tar hostname date split gzip bzip2"



# verify that each command we use exists

for command in $command_list; do

path=`which $command | grep "no $command in"`



if [ ! -x `which $command` -a "$path" ]; then

echo -e "nnERROR: $command not found! Check your $command_list and/or your $PATH"

exit -1

fi

done



# options for the tar command

tarOptions="--absolute-names --preserve-permissions --totals --ignore-failed-read --verbose --file"



# where to put the stage4

stage4Location=/mnt/backups/stage4



# name prefix

stage4prefix=$(hostname)-stage4-`date +%d.%m.%Y`



# exclude pattern. for example:

#exclude_pattern="--exclude=*.iso --exclude="*.bz2""

exclude_pattern=""



# these files/directories are always excluded

default_exclude_list="

--exclude=/tmp/*

--exclude=/var/tmp/*

--exclude=/lost+found/*

--exclude=/dev/*

--exclude=/proc/*

--exclude=/mnt/*

--exclude=/sys/*

--exclude=/usr/portage/*

--exclude=/var/log/*

--exclude=$stage4Location"



# depending on your choice these files or directories will additionally be excluded

custom_exclude_list="

--exclude=/usr/src/*

--exclude=/home/*"





# files/folder which are children of a folder in an exclude_list

default_include_list="

/var/log/emerge.log

/dev/null

/dev/console"



function verify()

{

for i in $1; do

if [ ! -e "`echo "$i" | cut -d'=' -f2 | cut -d'*' -f1`" ]; then

echo "ERROR: `echo "$i" | cut -d'=' -f2` not found! Check your "$2

fi

done

}



echo ""



# check the folder/files stored in $custom_exclude_list exist

verify "$default_exclude_list" "$default_exclude_list"



# check the folder/files stored in $default_exclude_list exist

verify "$custom_exclude_list" "$custom_exclude_list"



# check the folder/files stored in $custom_exclude_list exist

verify "$default_include_list" "$default_include_list"





# print out the version

echo -e "nBackup script $version"

echo -e "===================="





# how do you want to backup?

echo -e "nWhat do you want to do? (Use CONTROL-C to abort)n

Fast (tar.gz):

(1) Minimal backup

(2) Interactive backup





Best (tar.bz2):

(3) Minimal backup

(4) Interactive backupn"



while [ "$option" != '1' -a "$option" != '2' -a "$option" != '3' -a "$option" != '4' ]; do

echo -en "Please enter your option: "

read option

done



case $option in

[1,3])

stage4Name=$stage4Location/$stage4prefix-minimal.tar



default_exclude_list="$default_exclude_list $custom_exclude_list"



case $option in

1) stage4postfix="gz"

zip="gzip ";;

*) stage4postfix="bz2"

zip="bzip2 ";;

esac

;;



[2,4])

stage4Name=$stage4Location/$stage4prefix-custom.tar



for folder in $custom_exclude_list; do

echo -en "nDo you want to backup" `echo "$folder" | cut -d'=' -f2`"? (y/n) "

read answer

while [ "$answer" != 'y' -a "$answer" != 'n' ]; do

echo -en "Do you want to backup" `echo "$folder" | cut -d'=' -f2`"? (y/n) "

read answer

done

if [ "$answer" == 'n' ]; then

default_exclude_list="$default_exclude_list $folder"

fi

done



case $option in

2) stage4postfix="gz"

zip="gzip";;

*) stage4postfix="bz2"

zip="bzip2";;

esac

;;

esac



tar_command="tar --create $tarOptions $stage4Name $default_include_list $exclude_pattern"

tar_command_append="tar $default_exclude_list $exclude_pattern $tarOptions $stage4Name -r /"

zip_command="$zip -f $stage4Name"



# show what will be done

echo -ne "ncreating the stage4 at $stage4Location with the following command:nn"$tar_command

echo -n " && "$tar_command_append

echo -n " && "$zip_command



# everything is set, are you sure to continue?

echo -ne "nnDo you want to continue? (y/n) "

read answer

while [ "$answer" != 'y' ] && [ "$answer" != 'n' ]; do

echo -ne "Do you want to continue? (y/n) "

read answer

done



if [ "$answer" == 'y' ]; then



# check whether the file already exists (do that before the *.tar files have been created)

if [ -a "$stage4Name.$stage4postfix" ]; then

echo -en "nDo you want to overwrite $stage4Name.$stage4postfix? (y/n) "

read answer

while [ "$answer" != 'y' ] && [ "$answer" != 'n' ]; do

echo -en "Do you want to overwrite $stage4Name.$stage4postfix? (y/n) "

read answer

done

if [ "$answer" == 'n' ]; then

echo -e "n* There's nothing to do ... Exiting"

exit 0;

fi

fi



# if necessary, create the stage4Location

if [ ! -d "$stage4Location" ] ; then

echo "* creating directory $stage4Location"

mkdir -p $stage4Location

fi



# mount boot

echo -e "n* mount bootn"

mount /boot >/dev/null 2>&1



# do the backup

$tar_command

$tar_command_append

echo -e "n* $zip $stage4Name"

$zip_command



# copy the current world file to the stage4 location

#echo -e "n* creating stage4 overview $stage4Name.txt"

#cp /var/lib/portage/world $stage4Name.txt >/dev/null 2>&1



# finished, clean up

echo -e "* stage4 is done"

echo "* umounting boot"

umount /boot



else

echo -e "n* There's nothing to do ... Exiting"

fi



# Split the archive into chunks (uncomment the 3 lines if you want to split the stage4)

#echo -e "* split $stage4Name.$stage4postfix"

#split --suffix-length=1 --bytes=690m $stage4Name.$stage4postfix "$stage4Name.$stage4postfix"_

#echo "* splitting is done"











복원 방법:

1. boot off a live-cd and repartition and create filesystems as necessary

2. eventually reboot, using option: gentoo docache

3. umount /mnt/cdrom

4. remove the live-cd and insert the cd with the stage4

5. mount /dev/cdrom /mnt/cdrom

6. mount /dev/hdaX /mnt/gentoo

7. mkdir /mnt/gentoo/boot

8. mount /dev/hdaX /mnt/gentoo/boot

9. tar xzvpf /mnt/cdrom/host-stage4-18.04.2005-custom.tar.gz -C /mnt/gentoo/

or

9. tar xjvpf /mnt/cdrom/host-stage4-18.04.2005-custom.tar.bz2 -C /mnt/gentoo/

10. mount -t proc none /mnt/gentoo/proc

11. mount -o bind /dev /mnt/gentoo/dev

12. chroot /mnt/gentoo /bin/bash

13. env-update

14. source /etc/profile



if in need adjust necessary files (/etc/fstab, /boot/grub/grub.conf) and/or install grub



15. emerge sync (rebuild portage tree)

16. exit

17. cd /

18. umount /mnt/cdrom

19. remove backup cd

20. umount /mnt/gentoo/boot

21. umount /mnt/gentoo/dev

22. umount /mnt/gentoo/proc

23 umount /mnt/gentoo

24. Reboot




--------------------------------------------------광고(Advertising)-------------------------------------------------------------------------------------