| View previous topic :: View next topic |
| Author |
Message |
lazy_bum l33t


Joined: 16 Feb 2005 Posts: 665
|
Posted: Tue Sep 16, 2008 6:35 am Post subject: |
|
|
Proponuję do drugiego sposobu dodać również "jak odzyskać system z backupu", skoro ma być maksymalnie proste. (-: _________________ roslin uberlay | grubelek |
|
| Back to top |
|
 |
SlashBeast Moderator


Joined: 23 May 2006 Posts: 2540 Location: Zduńska Wola, Poland.
|
Posted: Tue Sep 16, 2008 10:59 am Post subject: |
|
|
| Coś się wymyśli, ten skrypt z pierwszego posta napisze troche inaczej by był bardziej friendly ale to już wieczorem. |
|
| Back to top |
|
 |
C1REX l33t


Joined: 02 Jan 2004 Posts: 617 Location: London
|
Posted: Tue Sep 16, 2008 5:19 pm Post subject: |
|
|
Ten skrypt jest bardzo friendly IMHO.
A co do odzyskiwania systemu: chyba jednak odpalenie innego distra -> format -> rozpakowanie backupu nadal pozostaje najlepszą metodą.
Ma ktoś pomysł na coś prostszego? Da się to jakoś zautomatyzować?
Ideałem byłoby, by z działającego gentoo (lub chroota, jeśli gentoo padło kompletnie) dało się wpisacać coś w stylu:
#backup --recovery
i skrypt sam rozpakował backupa + ściągnął najnowszy snapshot portage.
Da się?
BTW: Do skryptu dodałem -p przy mkdir jak doradził Damjanek. Dzięki temu nie ma errorów, że katalog już istnieje. _________________ I'm sorry for language mistakes. My native language is polish. |
|
| Back to top |
|
 |
SlashBeast Moderator


Joined: 23 May 2006 Posts: 2540 Location: Zduńska Wola, Poland.
|
|
| Back to top |
|
 |
C1REX l33t


Joined: 02 Jan 2004 Posts: 617 Location: London
|
Posted: Wed Sep 17, 2008 12:13 am Post subject: |
|
|
Przetestowałem pierwszą wersję.
Właśnie zauważyłem, że --exclude=./usr/src/*
Po co?
U siebie wywalam ten wpis. Moim zdaniem powinien być opcjonalnie. Dobrze, że miałem .config skopiowany, bo do mego lapka trochę czasu mi zajęło to poustawiać.
No i każdy musi uważać z /mnt, jeśli ma tam duże partycje podmontowane. Ja właśnie sobie zdałem sprawę, że tam są dwie inne dystrybucje podmontowane.
BTW: "doświadczeniom", a nie "doświadczenią. Niby drobiazg, ale razi taki brzydki ort w takim ładnym skrypcie.
Do wersji 0.3 możesz dać plik konfiguracyjny oddzielnie od wykonywalnego.
To jeszcze bardziej ułatwi edycję i zwiększy przejrzystość.
0.4 mogłoby być w overlayu. 0.5 w portage. 1.0 w gałęzi stabilnej : ) _________________ I'm sorry for language mistakes. My native language is polish. |
|
| Back to top |
|
 |
SlashBeast Moderator


Joined: 23 May 2006 Posts: 2540 Location: Zduńska Wola, Poland.
|
Posted: Wed Sep 17, 2008 7:38 am Post subject: |
|
|
Poprawione, /usr/src jest olewane bo zajmje zbyt wiele, ale moge dopisac robienia dumpa pliku .config z /usr/src/linux lub konfigra z odpalonego kernela, lub oba.
Co do /mnt to generalnie nie problem, gdy jest mount /dev/root /tmp/rootfs otrzymujemy tylko rootfs, nie wazne, ze np. w /mnt/dropzone mamy podmontowane dropzone a w nim setki plików, w /tmp/rootfs/mnt bedzie katalog dropzone - tak, ale pusty.
żeby to było w portage czy overlayu to brakuje mu dużo... baaardzo dużo.
Wieczorem naucze skrypt montowania dodatkowych partycji w stylu /var /usr /boot i tak dalej.
Myślę też nad robieniem tarballa bez kompresji a potem pakowania go np. przez pbzip2 (ukłon w strone wielu procesorów/rdzeni). |
|
| Back to top |
|
 |
C1REX l33t


Joined: 02 Jan 2004 Posts: 617 Location: London
|
Posted: Wed Sep 17, 2008 2:39 pm Post subject: |
|
|
Byłoby super, gdyby nie kasowało configa z kernela. Cała reszta faktycznie sporo czasu zajmuje przy pakowaniu, ale configa szkoda tracić. _________________ I'm sorry for language mistakes. My native language is polish. |
|
| Back to top |
|
 |
d0b Apprentice


Joined: 30 Jul 2007 Posts: 151 Location: Poland / London, UK
|
Posted: Fri Sep 26, 2008 12:15 am Post subject: |
|
|
Więc jak tam jest już nowa wersja skryptu ?? w sumie C1REX podał mi ten link i pomysł aby zrobić backupa za co dzięki, ale generalnie nie bardzo wiem jakie będą tego sutki więc czekam na finalną wersję skryptu od SlashBeast, a tak na marginesie mam pytanie czy ten skrypt robi też backup samego jądra ?? bo mi się wydaje że mojej jajko jest na maxa skaszanione i ciekawi mnie czy jest jakaś opcja aby zostawić wszelkie zainstalowane pakiety, configi etc a wgrać jakoś samo jajko ?? Nie mogę za cholerę sobie poradzić z kilkoma sprawami i już jestem gotów na format i świeży system lecz szkoda mi kurde tego co mam już porobione z gentoo. |
|
| Back to top |
|
 |
SlashBeast Moderator


Joined: 23 May 2006 Posts: 2540 Location: Zduńska Wola, Poland.
|
Posted: Fri Sep 26, 2008 8:21 am Post subject: |
|
|
Sporo brakuje w tym skrypcie a ja mam ostatnio tyle pracy, że w ogóle nie zajmuje się takimi rzeczami jak ten skrypt, może w weekend. Na_razie jako tako to działa.
Co do kernela, przeca masz jego obraz w /boot, mzoesz go wywalić, zrobić na nowo, itd.
Arfrever: Ortografia |
|
| Back to top |
|
 |
C1REX l33t


Joined: 02 Jan 2004 Posts: 617 Location: London
|
Posted: Sat Sep 27, 2008 12:11 am Post subject: |
|
|
Skrypt działa. Robi działające backupy.
A jak ktoś ma obawy, że coś się może posypać, to można ręcznie to zrobić, jak to podałem w pierwszej części how-to. Jedno polecenie. _________________ I'm sorry for language mistakes. My native language is polish. |
|
| Back to top |
|
 |
f15091983 n00b

Joined: 15 Jan 2006 Posts: 34
|
Posted: Mon Sep 29, 2008 1:26 pm Post subject: |
|
|
Witam
Ten skrypt jest zmodyfikowany o obsługę wielowątkowości, przez co w pełni wykorzysta możliwości wielordzeniowych procesorów.
| Code: |
#!/bin/bash
# Backup script for Gentoo Linux
# mkstage4.sh is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# mkstage4.sh is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# Copyright: Reto Glauser aka blinkeye
# Mailto: stage4 at blinkeye dot ch
# Homepage: http://blinkeye.ch
# Forum post: http://forums.gentoo.org/viewtopic-t-312817.html
# Date: 2005-11-14
version=v3.6
basename=`basename $0`
find=/usr/bin/find
tar=/bin/tar
# these are the commands we actually need for the backup
command_list=(cut date echo $find grep hostname mount 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
help="\nUsage:\n\nsh `basename $0` [[-v]|[--verbose]] [[-s]|[--split]] \n\nTo run the script NOT in verbose mode comes in handy if you want to see only the errors that occur during the backup.\n"
# Defaults to creating one tarball
tar_output="--file"
# split command
split_options="--suffix-length=1 --bytes=685m"
# options for the tar command
tarOptions=" --preserve-permissions --create --absolute-names --totals --ignore-failed-read"
# where to put the stage4
stage4Location=/tmp/backups/stage4
# name prefix
stage4prefix=`hostname`-stage4-`date +\%Y.\%m.\%d`
# patterns which should not be backed up (like iso files).
# example: default_exclude_pattern="*.iso *.divx"
# These pattern count only for files NOT listed in the $custom_include_list.
default_exclude_pattern=""
# these files/directories are always excluded. don't add trailing slashes.
# don't touch it unless you know what you are doing!
# /var/db and /var/cache/edb are intentionally added here. they are listed
# in $default_include_folders
default_exclude_list="
/dev
/lost+found
/mnt
/proc
/sys
/tmp
/usr/portage
/usr/src
/var/log
/var/tmp
/var/db
/var/cache/edb
/varia
$stage4Location
`echo $CCACHE_DIR`"
# files/devices/folders, which need to be backed up (preserve folder structure).
# don't touch it unless you know what you are doing! no recursive backup of folders.
# use $default_include_folders instead.
default_include_files="
/dev/null
/dev/console
/home
/mnt
`find /mnt -name .keep`
/proc
/sys
/tmp
/usr/portage
/usr/src
/var/log/emerge.log
/usr/src/linux-`uname -r`/.config"
# folders, which need to be backed up recursively on every backup.
# don't touch it unless you know what you are doing! the reason for this
# variable is that some users add /var to the $default_exclude_list. here
# we ensure that portage's memory is backed up in any case.
default_include_folders="
/var/db"
# IMPORTANT: A minimal backup will EXCLUDE files/folders listed here. A custom backup will
# include/exclude these files/folders depening on your answer.
custom_include_list="
/home/*
/usr/src/*
/usr/portage/
/mnt/*"
# add files/folders here which are subfolders of a folder listed in $custom_include_list which should NOT
# be backed up. eg.
#custom_exclude_list="/home/foo/mp3 /home/foo/downloads /home/foo/.*"
custom_exclude_list=""
# Only files/folders within the $custom_include_list are checked against these patterns
# custom_exclude_pattern="*.mp3 *.iso"
custom_exclude_pattern=""
# the find_command
find_command="$find /*"
# don't backup anything which matches pattern listed in $default_exclude_pattern
for pattern in $default_exclude_pattern; do
find_command="$find_command -not -name $pattern"
done
# assemble the find_command
function find_files()
{
for folder in $default_exclude_list; do
find_command="$find_command -path $folder -prune -o"
done
find_command="$find_command -print"
for i in $default_include_files; do
find_command="echo $i; $find_command"
done
for i in $default_include_folders; do
if [ -d $i ]; then
find_command="$find $i; $find_command"
else
find_command="echo $i; $find_command"
fi
done
}
# check the exclude/include variables for non-existing entries
function verify()
{
for i in $1; do
if [ ! -e "`echo "$i" | cut -d'=' -f2 | cut -d'*' -f1`" -a "$i" != "/lost+found" -a "$i" != "$stage4Location" ]; then
echo "ERROR: `echo "$i" | cut -d'=' -f2` not found! Check your "$2
exit 0
fi
done
}
# check input parameters
while [ $1 ]; do
case $1 in
"-h" | "--help")
echo -e $help
exit 0;;
"-v" | "--verbose")
verbose=$1;;
"-s" | "--split")
tar_output="--split";;
"");;
*)
echo -e $help
exit 0;;
esac
shift
done
echo ""
# check folder/files listed in $default_exclude_list exist
verify "$default_exclude_list" "\$default_exclude_list"
# check files listed in $default_include_files exist
verify "$default_include_files" "\$default_include_files"
# check folder listed in $default_include_folders exist
verify "$default_include_folders" "\$default_include_folders"
#check folder listed in $custom_include_list exist
verify "$custom_include_list" "\$custom_include_list"
#check folder listed in $custom_exclude_list exist
verify "$custom_exclude_list" "\$custom_exclude_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 backup
(5) Parallel backup -- (tar.bz2) require 7zip
\n"
while [ "$option" != '1' -a "$option" != '2' -a "$option" != '3' -a "$option" != '4' -a "$option" != '5' ]; do
echo -en "Please enter your option: "
read option
done
case $option in
[1,3])
stage4Name=$stage4Location/$stage4prefix-minimal.tar;;
[2,4,5])
stage4Name=$stage4Location/$stage4prefix-custom.tar
for folder in $custom_include_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
find_command="$find_command -path $folder -prune -o"
else
custom_find="$find $folder"
for i in $custom_exclude_pattern; do
custom_find="$custom_find -name $i -o"
done
for i in $custom_exclude_list; do
custom_find="$custom_find -path $i -prune -o"
done
find_command="$custom_find -print; $find_command"
fi
done ;;
esac
# add $custom_include_list to the $default_exclude_list as we assembled
# $custom_find with $custom_include_list already.
default_exclude_list="$default_exclude_list $custom_include_list"
case $option in
[1,2])
stage4postfix="gz"
zip="--gzip";;
[3,4])
stage4postfix="bz2"
zip="--bzip2";;
[5])
parallel=1
stage4postfix="bz2"
pzip="7z a -si -bd -mmt=on -md=256m -tbzip2";;
esac
# mount boot
echo -e "\n* mounting boot"
mount /boot >/dev/null 2>&1
# find the files/folder to backup
find_files
find_command="($find_command)"
# create the final command
if [ "$parallel" == "1" ]; then
tar_command=" $find_command | $tar $tarOptions $verbose --no-recursion -T - | $pzip $stage4Name.$stage4postfix"
else
if [ "$tar_output" == "--file" ]; then
tar_command="$find_command | $tar $zip $tarOptions $verbose --file $stage4Name.$stage4postfix --no-recursion -T -"
else
tar_command="$find_command | $tar $zip $tarOptions $verbose --no-recursion -T - | split $split_options - "$stage4Name.$stage4postfix"_"
fi
if [ "$verbose" ]; then
echo -e "\n* creating the stage4 in $stage4Location with the following command:\n\n"$tar_command
fi
fi
# everything is set, are you sure to continue?
echo -ne "\nDo 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.
if [ "$tar_output" == "--split" ]; then
overwrite="`ls "$stage4Name.$stage4postfix"_* 2>&1 | grep -v 'No such file'`"
else
overwrite="$stage4Name.$stage4postfix"
fi
if [ -a "`echo "$overwrite" | grep "$overwrite" -m1`" ]; then
echo -en "\nDo you want to overwrite $overwrite? (y/n) "
read answer
while [ "$answer" != 'y' ] && [ "$answer" != 'n' ]; do
echo -en "Do you want to overwrite $overwrite? (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
echo -e "\n* Please wait while the stage4 is being created.\n"
# do the backup.
sh -c "$tar_command"
# finished, clean up
echo -e "\n* stage4 is done"
echo "* umounting boot"
umount /boot >/dev/null 2>&1
# Integrity check
echo -e "* Checking integrity"
if [ "$zip" == "--gzip" ]; then
zip="gzip"
else
zip="bzip2"
fi
if [ "$tar_output" == "--split" ]; then
if [ "`cat "$stage4Name.$stage4postfix"_*"" | $zip --test 2>&1`" != "" ]; then
echo -e "* Integrity check failed. Re-run the script and check your hardware."
exit -1
fi
else
if [ "`$zip --test $stage4Name.$stage4postfix 2>&1`" != "" ]; then
echo -e "* Integrity check failed. Re-run the script and check your hardware."
exit -1
fi
fi
# everything went smoothly"
echo -e "* Everything went smoothly. You successfully created a stage4."
else
echo -e "\n* There's nothing to do ... Exiting"
fi
|
Ten skrypt został przystosowany do moich potrzeb, i każdy powinien go zmodyfikować do własnego użytku. |
|
| Back to top |
|
 |
grahamm n00b

Joined: 18 May 2008 Posts: 7
|
Posted: Wed Oct 15, 2008 10:53 am Post subject: |
|
|
| Mam pytanie odnośnie skryptu z pierwszej strony. Powiedzmy ze mam gentoo skompilowane dla i686 zainstalowane na partycji xfs. Czy moge zrobic backup tego systemu i rozpakować archiwum na innym kompie? Czy to nie bedzie sie gryzlo? |
|
| Back to top |
|
 |
BeteNoire Veteran

Joined: 25 Sep 2005 Posts: 1827
|
Posted: Wed Oct 15, 2008 11:09 am Post subject: |
|
|
Jeśli sprzęt, układ partycji i ich rodzaj jest taki sam to możesz klonować bez obaw. Jeśli sprzęt jest inny, ale architektura procka ta sama, to musisz się tylko chootnąć do tego rozpakowanego i przekompilować kernel pod nowe urządzenia. _________________ powered by power plant |
|
| Back to top |
|
 |
grahamm n00b

Joined: 18 May 2008 Posts: 7
|
Posted: Wed Oct 15, 2008 11:25 am Post subject: |
|
|
Jeszcze takie szybkie pytanko:
Co grozi rozpakowaniem takiego stage'a na inny uklad partycji? |
|
| Back to top |
|
 |
BeteNoire Veteran

Joined: 25 Sep 2005 Posts: 1827
|
Posted: Wed Oct 15, 2008 11:58 am Post subject: |
|
|
Coś jakby lodówka w łazience i pralka w salonie
Nawet jeśli zamienisz coś kolejnością to musisz uważać, by dobrze podmontować na czas rozpakowywania - wtedy nie będzie problemu.
No i pamiętać o zmianie wpisów konfiguracji bootloadera i fstab. _________________ powered by power plant |
|
| Back to top |
|
 |
C1REX l33t


Joined: 02 Jan 2004 Posts: 617 Location: London
|
Posted: Wed Oct 15, 2008 1:47 pm Post subject: |
|
|
Sam tak robiłem. Niczym nie grozi. Ma się gentoo zainstalowane na nowym kompie w 5 minut.
Czasochłonna jest tylko edycja wszystkich potrzebnych plików konfiguracyjnych i ewentualnie rekompilacja jaja.
Jeśli na nowym kompie jest więcej partycji, niż same /, to trzeba je podmontować __przed__ rozpakowaniem stage'a.
EDIT: Problem może się pojawić, jak ma się zupełnie inny procek. Wtedy w najlepszym wypadku i tak trzeba przekompilować cały system pod nowego procka. W najgorszym wcale taki system nie będzie działał. _________________ I'm sorry for language mistakes. My native language is polish. |
|
| Back to top |
|
 |
pabliszer n00b

Joined: 02 Nov 2011 Posts: 1
|
Posted: Wed Nov 02, 2011 11:31 am Post subject: |
|
|
Witam to mój pierwszy post na tym forum i mam kilka pytań co do powyższego skryptu.
Po pierwsze jakie katalogi bądź pliki musze skopiować aby móc w pełni przywrócić system ( zaznaczam ze dopiero zaczynam przygode z Gentoo ).
Czy po uszkodzeniu systemu przywrócenie skopiowanych plików spowoduje powrót systemu do działania czy trzeba cos jescze robić. Czy są jeszcze jakieś inne narzędzia do robienia kopii (ale które można użyć w skryptach)?Prosiłbym jeszcze o odświerzenie linków bo nie działają.
I jeszcze pytanie co do opcji --exclude= co ona powoduje (proszę o wyjaśnienie ) ? |
|
| Back to top |
|
 |
Bastian82 n00b

Joined: 07 Feb 2011 Posts: 45 Location: Poznań
|
Posted: Fri Nov 04, 2011 5:04 pm Post subject: |
|
|
W pierwszym poscie masz w tym skrypcie excludowane katalogi za pomocą --EXCLUDE= , tak więc zeby system wstał (nie wdając sie juz w szczegóły) musisz backupować wszystkie katalogi prócz tych excludowanych. Jak sie już pewnie domyślasz, opcja ta wyłącza z tarballa te katalogi bo nie potrzebne do backupu. Jeżeli nie zmienia Ci się w zaden sposób wielkość partycji to nie trzeba nic więcej robić po wgraniu systemu z backupu.
Jakie jeszcze narzędzia? Ja to wole niżej - dd . |
|
| Back to top |
|
 |
|