Резервное копирование
SHS 29 июня, 2009 - 12:49
В общем поставил систему, все настроил, наладил. Собственно как можно забекапить корневой раздел? Чтоб в случае смерти системы распаковать рабочую среду.
Данная операция делает слепок диска : dd if=/dev/sda10 | bzip2 -cz9 > /mnt/backup/root_sda10.tar.bz2 (а это более 20GB)
»
- Для комментирования войдите или зарегистрируйтесь

Backup
Ну, можете посмотреть в сторону создания Stage4, где-то на gentoo-wiki
про неё было. Я лично вот таким скриптиком пользуюсь для создания
4-й стадии: http://dpaste.com/61054/
Stage4.excl - делайте сами, по Вашему усмотрению.
Спасибо
Благодарю, это именно то что мне и нужно!
Люди!!!
Скриптик не такой уж и большой...
Но вполне полезный.
Заслуживает несколько более продолжительной жизни.
#!/bin/bash # var: stagedir="//home/Ваша\ Директория/Backup/$(date +%Y%m%d)" stagefile="stage4_$(date +%Y%m%d).tar.bz2" mdfile="$(date +%Y%m%d).mdsum" # end var create_BackupDir() { mkdir -p "//home/Ваша\ Директория/Backup" } build_stage() { echo "-- Creating Stage4 "${stagedir}" directory" sleep 3 mkdir -p "${stagedir}" echo "-- Creating tar archive "${stagefile}" on "${stagedir}", please make more tea or cofee ;-) --" sleep 3 tar -cpjf "${stagedir}/${stagefile}" / -X "$HOME//stage4.excl" echo "-- Creating md5sum file "${mdfile}", please wait --" md5sum "${stagedir}/${stagefile}" > "${stagedir}/${mdfile}" } rebuild_stage() { rm -Rf "${stagedir}" echo "-- Removing "${stagedir}" --" build_stage } if [ -d //home/willhelm/Backup ]; then if [ -d "${stagedir}" ]; then echo "-- "${stagedir}" exist --" filelist=$(ls "${stagedir}") for i in "$filelist" ; do if [ "$i" = "$stagefile" ]; then echo "-- ${i} existing, abort --" break 2 else echo "--== Rebuilding backup archive ==--" rebuild_stage break 2 fi done else echo " -- "${stagedir}"is NOT directory or NOT file --" build_stage fi else create_BackupDir build_stage fi exit 0:wq
--
Live free or die
не хватает содержимого
не хватает содержимого stage4.excl.
Да и с /dev при развертывании с такого стейжа будут проблемы. (если не используется initrd).
Раз такое дело, то и я
Раз такое дело, то и я "похвастаюсь", скрипт mkstage4.sh не мой, чуть "допиленный" под мои нужды:
#! /bin/bash ## Backup script for Gentoo Linux # Last modification 2008.11.09 # Added check 'qlist' command exist and run saving list of installed packages with your USE-flags # Added "new" excluded dir - /usr/src, /usr/portage basename=$(basename $0) # these are the commands we actually need for the backup command_list=(cut date dd echo find grep hostname mount mkdir qlist sfdisk sh split tar umount uname which) # verify that each command we use exists. if one can't be found use $PATH and make a suggestion if possible. for command in ${command_list[@]}; do if [ ! -x "$(which $command 2>&1)" ]; then echo -e "\nERROR: $command not found! " base=$(basename $command) if [ "$(which $base 2>&1 | grep "no $(basename $command) in")" != "" ]; then echo -e "ERROR: $base is not in your \$PATH." fi exit -1 fi done # ############################################################################################################### ## This is a script to create a custom stage 4 tarball (System and boot backup) ## Please check the options and adjust to your specifics. echo "-=- Starting the Backup Script..." echo "-=-" echo "-=- Setting the variables..." ## Where MBR is written. disk_with_mbr="/dev/sda" ## The location of the stage 4 tarball. ## Be sure to include a trailing / patch_to_backup=/home/users/backup/ stage_for_location=$(date +%F)_system if [ ! -d ${patch_to_backup}${stage_for_location} ]; then if mkdir -p ${patch_to_backup}${stage_for_location}; then backup_dir=${patch_to_backup}${stage_for_location}/ ## The name of the stage 4 tarball. archive=${backup_dir}$(hostname)-stage4.tar.bz2 echo "-=- Backup directory ${backup_dir} created..." else echo "-=- Can't create ${backup_dir}. Please check ..." exit 1 fi else if [ -f ${archive} ]; then echo "-=- Backup file ${archive} exist, nothing to do..." exit 1 fi fi ## Directories/files that will be exluded from the stage 4 tarball. ## ## Add directories that will be recursively excluded, delimited by a space. ## Be sure to omit the trailing / dir_excludes=" /mnt/* /dev /lost+found /proc /sys /tmp /home /usr/src /var/tmp /var/run" ## ## Add files that will be excluded, delimited by a space. ## You can use the * wildcard for multiple matches. ## There should always be $archive listed or bad things will happen. file_excludes="${archive}" ## ## Combine the two *-excludes variables into the $excludes variable excludes="$(for i in ${dir_excludes}; do if [ -d $i ]; then \ echo -n " --exclude=$i/*"; fi; done) $(for i in ${file_excludes}; do \ echo -n " --exclude=$i"; done)" ## The options for the stage 4 tarball. tar_options="${excludes} --create --absolute-names --preserve-permissions --bzip2 --verbose --totals --file" echo "-=- Done!" echo "-=-" ## Mounting the boot partition echo "-=- Mounting boot partition, then sleeping for 5 seconds..." mount /boot sleep 5 echo "-=- Done!" echo "-=-" ## Creating a copy of the boot partition (copy /boot to /bootcpy). ## This will allow the archiving of /boot without /boot needing to be mounted. ## This will aid in restoring the system. echo "-=- Copying /boot to /bootcpy ..." cp -R /boot /bootcpy echo "-=- Done!" echo "-=-" echo "-=- Copying kernel config to /bootcpy ..." zcat /proc/config.gz > /bootcpy/config_$(uname -r) echo -=- Done! echo -=- echo "-=- Write list of installed packages ..." qlist -CU > ${backup_dir}installed_packages.txt echo "-=- Done!" ## echo "-=- Write README.txt ..." echo "For fix "Warning: unable to open an initial console."" >> ${backup_dir}Readme.txt echo "run /usr/local/sbin/fix_console.sh" >> ${backup_dir}Readme.txt echo "-=- Done!" ## Unmounting /boot echo "-=- Unmounting /boot then sleeping for 5 seconds..." umount /boot sleep 5 echo "-=- Done!" echo "-=-" ## Creating the stage 4 tarball. echo "-=- Creating custom stage 4 tarball \=\=\> ${archive}" echo "-=-" echo "-=- Running the following command:" echo "-=- tar ${tar_options} ${archive} /" tar ${tar_options} ${archive} /; echo "-=- Done!" ## Uncomment this portion to encrypt the stage4 using asymmetric encryption with GnuPG ## To get a list of available ciphers on your machine do #gpg --version ## Note: only aes aes192 aes256 and twofish should be used for large files (~1Gig & larger) ## To Restore: (cat together if split) and #gpg stage4.tar.bz2.gpg #echo -=- Starting Encryption Process usung asymmetric encryption with a public key -=- #cd $stage4Location #gpg --encrypt --batch --recipient [MY_PUB_KEY] --cipher-algo twofish --output $archive.gpg $archive #rm $archive #archive=$stage4Location$(hostname)-stage4.tar.bz2.gpg ## Uncomment this portion to encrypt the stage4 using symmetric encryption with GnuPG ## ## To get a list of ciphers on your machine do #gpg --version ## Note: only aes aes192 aes256 and Twofish should be used for large files (~1 gig & larger) ## To Restore: (cat together if split) and #gpg stage4.tar.bz2.gpg #echo -=- Starting Encryption Process usung symmetric encryption with a password -=- #cd $stage4Location #pass=PLEASE_CHANGE_ME_I_BEG_YOU! #echo $pass | gpg --batch --cipher-algo twofish --passphrase-fd 0 --symmetric $archive #rm $archive #archive=$stage4Location$(hostname)-stage4.tar.bz2.gpg ## Split the stage 4 tarball in cd size tar files. ## To combine the tar files after copying them to your ## chroot do the following: "cat *.tar.bz2 >> stage4.tar.bz2". ## or if encrypted do the following: "cat *.tar.bz2.gpg >> stage4.tar.bz2.gpg". ## Uncomment the following lines to enable this feature. #echo -=- Splitting the stage 4 tarball into CD size tar files... #split --bytes=700000000 ${archive} ${archive}. #echo -=- Done! ## Removing the directory /bootcpy. ## You may safely uncomment this if you wish to keep /bootcpy. echo "-=- Removing the directory /bootcpy ..." rm -rf /bootcpy echo "-=- Done!" echo "-=-" ## ## To store partition table info: ## The first of those saves the mbr and the second will store all partition info (including logical partitions, ## which aren't part of the mbr). echo "-=- Store MBR and partition table info ..." dd if=${disk_with_mbr} of=${backup_dir}mbr.save count=1 bs=512 sfdisk -d ${disk_with_mbr} > ${backup_dir}partitions.save echo "-=- Done!" echo "-=-" ## This is the end of the line. echo "-=- The Backup Script has completed!"Ну и по поводу "нерабочей" консоли. Мне помогает следующий скрипт fix_console.sh:
Я ♥ Gentoo & Funtoo
joe
Я конечно не в тему, но... Никто не подскажет, как научить joe
писать русские буквы (utf-8)? А то он всякую дребедень вместо кириллицы
выводитъ. Vim - оно конечно, но я привык к дядюшке джою :)
Вродебы и в .joerc всё что надо прописано, и в man писано, что utf-8
поддерживается; да вот как-то криво.
Очень не в тему. Начинайте
Очень не в тему. Начинайте новую.
Текстовый редактор vi имеет два режима работы: в первом он пищит, а во втором — всё портит.
/dev и тд.
Так стоит запаковывать содержимое /dev /sys или нет? Т. е. чтоб при развертке stage4 все работало. ))
Я запаковал со следующими исключениями:
.bash_history
/dev/*
/tmp/*
/mnt/backup/*
/proc/*
/sys/*
/usr/src/*
/usr/portage/*
Незнаю будет ли работать при развертке ))
Надо монтировать корневой
Надо монтировать корневой раздел в сторонке, и тогда можно тарить всё кроме /var/tmp /tmp /var/run и т.п. ибо /proc /sys - пустые, а /dev - с необходимым минимумом статических дев-ов.
backup
То есть монтируемся к примеру с livecd и бэкапим со следующими исключениями:
.bash_history
/tmp/*
/var/tmp/*
/var/run/*
/mnt/backup/*
/proc/*
/sys/*
/usr/src/*
/usr/portage/*
Это получается /dev бэкапится со статическими девайсами, /sys /proc как пустые папки? Еще спорный вопрос по поводу /var/tmp где-то слышал там могут настройки валяться всякие. К примеру у себя я там нашел alsaconf.cards
stage4.excl
В общем оптимальный вариант чтоб не возникало проблем.
Грузимся с liveCD, удаляем в /mnt/gentoo/var/tmp/ то что не нужно и бэкапим систему с исключениями:
.bash_history
/mnt/gentoo/tmp/*
/mnt/gentoo/usr/src/*
/mnt/gentoo/usr/portage/*