Download Przyrostowy backup na dysk dedykowany - bezpieczniejsze niż RAID

Dyskusja w 'Archiwizacja i przywracanie' rozpoczęta przez użytkownika Silas Mariusz, 4 Maj 2015.

Ładowanie...
  1. Silas Mariusz
    Offline

    Silas Mariusz SysOp Administrator

    Dołączył:
    5 Kwiecień 2008
    Wiadomości:
    6 033
    Miejscowość:
    Nowy Sącz
    Local Time:
    12:39
    Oceny:
    +1 340 / 30 / -5
    Followers:
    22
    QNAP:
    TVS-x71
    Ethernet:
    1 GbE
    TVS-x71 1 GbE
    Jak to działa:
    Serwer TS-451 skonfigurowany z 4 dyskami w trybie pojedynczym. Dysk numer 4 jest zarezerwowany tylko do kopii zapasowej kluczowych danych z dysków 1-3. Kopia jest wyzwalana raz dziennie... Każde dyski są skonfigurowane pojedynczo.

    Zalety takiego rozwiązania?
    Jeśli myślisz, że RAID to backup i załatwia sprawę to jesteś w błędzie.
    Pomyśl... Kupiłeś 4 dyski i zrobiłeś z nich RAID. W pracy każdy dysk był utilizowany tak samo przez ostatnie 2 lata. Który z nich zużył się najbardziej? Wszystkie!

    Kiedy jeden z dysków będzie na wykończeniu, bierz pod uwagę, że i zaraz kolejne dyski scenariusz śmierci czeka.

    W przypadku konfiguracji pojedynczych dysków zamiast równoległej pracy wszystkich w RAID'zie, tylko dysk numer 1 będzie najczęściej używany. Wszystkie codzienne usługi tj. Torrent, Stacja monitoringu i etc... zostaną skierowane na ten dysk. Pozostałe dyski na, których znajdują się multimedia oraz prywatne dane, będą rzadziej wykorzystywane a tym samym zwiększy się ich żywotność.
    Mało tego, na dysk numer 4 zostały zaplanowane dzienne kopie co zdecydowanie zwiększy bezpieczeństwo krytycznych danych!

    O zastosowaniu RAID i czym on naprawde jest już pisaliśmy na forum wiele razy...

    Rozwiązanie:
    1. Pobierz makebackup
    Kod (Bash):
    1. cd /share/Public
    2. wget http://pool.qnapclub.pl/projects/tools/makebackup/makebackup.tar.gz
    3. tar zxvf makebackup.tar.gz && rm makebackup.tar.gz
    4. cd .makebackup
    2. Edytuj w udziale sieciowym Public/.makebackup pliki backup.conf oraz backup.lst w którym określ katalogi źródłowe, które chcesz archiwizować:

    3. Uruchom mkbackup.sh
    Kod (Bash):
    1. ./mkbackup.sh
    4. Jeśli wszystko działa w porządku, dodaj skrypt do crontab'a, np. za pomocą CronWeb:
    Kod (Text):
    1. 15      5       *       *       *       sh /share/Public/mkbackup/makebackup.sh
    Source code:
    Kod (Bash):
    1. #!/bin/bash
    2. : ${NAME=backup}
    3. ##
    4. ##   Left-To-Right Backup for QNAP
    5. ##
    6. ##   Copyright © 2014, Silas Mariusz <silas@qnap.com.antispam>
    7. ##
    8. ##                     QNAP Club Polska
    9. ##
    10. ##
    11. ##   This program is free software; you can redistribute it and/or modify
    12. ##   it under the terms of the GNU General Public License as published by
    13. ##   the Free Software Foundation; either version 2, or (at your option)
    14. ##   any later version.
    15. ##
    16. ##   This program is distributed in the hope that it will be useful,
    17. ##   but WITHOUT ANY WARRANTY; without even the implied warranty of
    18. ##   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19. ##   GNU General Public License for more details.
    20. ##
    21. ##   You should have received a copy of the GNU General Public License
    22. ##   along with this program; if not, write to the Free Software Foundation,
    23. ##   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    24. ##
    25. ##   The latest version of this software can be obtained here:
    26. ##
    27. ##   https://forum.qnap.net.pl/
    28. ##
    29. ##
    30. ##   FILE: backup.sh
    31. ##
    32. ##   RELEASE: 0.4 (beta)
    33. ##   DATE: 2015-05-03
    34. ##
    35.  
    36.  
    37. ##   GENERAL VARIABLES
    38. [[ ! -d "/var/run" ]] && exit 1
    39. LOCK="/var/run/${NAME}.lock"
    40. LOCK_DIR="/var/run/${NAME}"
    41. RETVAL=0 ; _RETVAL=
    42.  
    43. ##   Set environment paths ...
    44. _PATHS=\
    45. /bin:\
    46. /sbin:\
    47. /usr/bin:\
    48. /usr/sbin:\
    49. /usr/local/bin:\
    50. /usr/local/sbin:\
    51. /opt/bin:\
    52. /opt/sbin:\
    53. /opt/local/bin:\
    54. /opt/local/sbin:\
    55. :
    56.  
    57. _LD_PATHS=\
    58. /opt/local/lib:\
    59. /opt/lib:\
    60. :
    61.  
    62. export PATH=$_PATHS:$PATH:$_PATHS
    63. #export LD_LIBRARY_PATH=$_LD_PATHS:$LD_LIBRARY_PATH:$_LD_PATHS
    64.  
    65. ##   Ansi colors
    66. ##   -----------------------------------------------------------------
    67. ##   Normal Colors        Bold Colors             # Color
    68. ##   ---------------------------------------------#-------------------
    69. black='\e[0;30m'    ; bblack='\e[1;30m'     ; # Black
    70. red='\e[0;31m'      ; bred='\e[1;31m'   ; # Red
    71. green='\e[0;32m'    ; bgreen='\e[1;32m'     ; # Green
    72. yellow='\e[0;33m'   ; byellow='\e[1;33m'    ; # Yellow
    73. blue='\e[0;34m'     ; bblue='\e[1;34m'  ; # Blue
    74. purple='\e[0;35m'   ; bpurple='\e[1;35m'    ; # Purple
    75. cyan='\e[0;36m'     ; bcyan='\e[1;36m'  ; # Cyan
    76. white='\e[0;37m'    ; bwhite='\e[1;37m'     ; # White
    77. ##   ---------------------------------------------#-------------------
    78. ##   Background
    79. on_black='\e[40m'   ;           # On Black
    80. on_red='\e[41m'     ;           # On Red
    81. on_green='\e[42m'   ;           # On Green
    82. on_yellow='\e[43m'  ;           # On Yellow
    83. on_blue='\e[44m'    ;           # On Blue
    84. on_purple='\e[45m'  ;           # On Purple
    85. on_cyan='\e[46m'    ;           # On Cyan
    86. on_white='\e[47m'   ;           # On White
    87. ##   ---------------------------------------------#-------------------
    88. ##   Colors Presets
    89. alert="${bwhite}${on_red}"  ; i_alert="${bred}${on_white}"  #alert
    90. note="${bwhite}${on_blue}"  ; i_note="${bblue}${on_white}"  #note
    91. info="$note"            ; i_info="$i_note"      #info
    92. ##   ---------------------------------------------#-------------------
    93. ##   Reset colour/restore default
    94. nc="\e[m"
    95. ##   ---------------------------------------------#--------[ DONE ]---
    96.  
    97. ##   Environment
    98. fd=0                    # stdin
    99. export HOME=/root
    100. export TERM=xterm
    101. export USER=admin
    102. export PWD=/root
    103. export EDITOR=/bin/vi
    104. export LOGNAME=admin
    105.  
    106.  
    107. : ${AWK=awk}
    108.  
    109. ##   interactive shell? then keep user attention on the err msg
    110. ##   -----------------------------------------------------------------
    111. if [ -t "$fd" ] || [ -p /dev/stdin ]; then
    112.     echo -n "]0; logman-[QNAP] "
    113. fi
    114.  
    115. ##   Signals
    116. SIGNAL_HUP=1        ; SIGNAL_INT=2      ; SIGNAL_QUIT=3     ;   SIGNAL_ILL=4
    117. SIGNAL_TRAP=5       ; SIGNAL_ABRT=6     ; SIGNAL_BUS=7      ;   SIGNAL_FPE=8
    118. SIGNAL_KILL=9       ; SIGNAL_USR1=10    ; SIGNAL_SEGV=11    ;   SIGNAL_USR2=12
    119. SIGNAL_PIPE=13      ; SIGNAL_ALRM=14    ; SIGNAL_TERM=15    ;   SIGNAL_STKFLT=16
    120. SIGNAL_CHLD=17      ; SIGNAL_CONT=18    ; SIGNAL_STOP=19    ;   SIGNAL_TSTP=20
    121. SIGNAL_TTIN=21      ; SIGNAL_TTOU=22    ; SIGNAL_URG=23     ;   SIGNAL_XCPU=24
    122. SIGNAL_XFSZ=25      ; SIGNAL_VTALRM=26  ; SIGNAL_PROF=27    ;   SIGNAL_WINCH=28
    123. SIGNAL_IO=29        ; SIGNAL_PWR=30     ; SIGNAL_SYS=31     ;   #End
    124.  
    125. # uint signal (uint <pid>, int <signal number>|string <signal name>)
    126. function signal {
    127.     local -i PID=$1 SIGNAL=$2  ## Automatically expands if $1 is a variable.
    128.     kill -s "$SIGNAL" "$PID" 2>&"$NULL"
    129. }
    130.  
    131. # debug exec - (if _DEBUG is non zero)
    132. function DEBUG()
    133. {
    134.     [[ "$_DEBUG" == "0" ]] || $@
    135. }
    136.  
    137. function _exit()
    138. {
    139.     echo -e "$*"
    140.     echo
    141.  
    142.     # interactive shell? then keep user attention on the err msg
    143.     if [[ -t "$fd" ]] || [[ -p /dev/stdin ]]; then
    144.         echo -n "]0; ! ERROR          - - - - -  " ; sleep 1
    145.         echo -n "]0; - - - - -           ERROR ! " ; sleep 1
    146.         echo -n "]0;  - - - - -           ERROR! " ; sleep 1
    147.         echo -n "]0; - - - - -           ERROR ! " ; sleep 1
    148.         echo -n "]0; !ERROR          - - - - -   " ; sleep 1
    149.     fi
    150.  
    151.     exit 1
    152. }
    153.  
    154. #alias strip_esc='sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K|A|B|C]//g"'
    155. alias strip_esc='sed -r "s/\x1B[\[|\(]([0-9]{1,2}(;[0-9]{1,2})?)?[m|K|A|B|C|E|J|S|Z|H]//g"'
    156. shopt -s expand_aliases
    157.  
    158. # Message to terminal and system log
    159. # ###########################################################################
    160. _log() {
    161.     local msg_type="info"
    162.     local write_msg="/sbin/log_tool -t0 -u$NAME -p127.0.0.1 -mlocalhost -a"
    163.     local message="$NAME: ${*:-"Unspecified Notice"}"
    164.     [ "$_QUIET" != "1" ] && echo -e "(${green}$msg_type${nc}) $message"
    165.     # save to system Event Log only when in DEBUG mode
    166.     [[ "$_DEBUG" == "1" ]] && $write_msg "($msg_type) $(echo $message | strip_esc)"
    167. }
    168.  
    169. # Warning message to terminal and system log
    170. # ###########################################################################
    171. _warn() {
    172.     local msg_type="warn"
    173.     local write_warn="/sbin/log_tool -t1 -u$NAME -p127.0.0.1 -mlocalhost -a"
    174.     local message="$NAME: ${*:-"Unknown Warning"}" && $write_warn "($msg_type) $(echo $message | strip_esc)"
    175.     echo -e "(${red}$msg_type${nc}) $message"
    176. }
    177.  
    178. # Write error log message and exit
    179. # ###########################################################################
    180. _err(){
    181.     local msg_type="err!"
    182.     local write_err="/sbin/log_tool -t2 -u$NAME -p127.0.0.1 -mlocalhost -a"
    183.     local message="$NAME: ${*:-"Unknown Error"}" && $write_err "($msg_type) $(echo $message | strip_esc)"
    184.     _exit "(${alert}$msg_type${nc}) $message \n"
    185. }
    186.  
    187. available() {
    188.     type -t "$1" >/dev/null && return 0
    189.     return 1
    190. }
    191.  
    192. need() {
    193.     available "$1" && return 0
    194.     _err needed command was not found: $1
    195.     exit 1
    196. }
    197.  
    198. alias finddev='getcfg "PhysicalDisk_$DISKNO" pd_sys_name -f /etc/enclosure_0.conf -d error | cut -d \/ -f 3'
    199. # Let external disk go sleep...
    200. drive_readd() {
    201.     _device=$($finddev)
    202.  
    203.     if [[ "$_device" == "error" ]] || [[ ! -x "/dev/$_device" ]]; then
    204.         echo "Hardware rescaning... (About 2 minutes)"
    205.         scsihosts=$(ls -1 "/sys/class/scsi_host/" | grep host | tr -d "@" | tac)
    206.         for i in $scsihosts ; do
    207.             _sd_dev=$(ls -1 /sys/block/ | grep sd | tr -d "/") ; echo Found: $_sd_dev
    208.             echo "0 0 0" >"/sys/class/scsi_host/$i/scan" 2>/dev/null
    209.             _device=$($finddev)
    210.             [[ "$_device" != "error" ]] && [[ -e "/dev/$_device" ]] && break
    211.         done
    212.  
    213.         sleep 10
    214.         sync
    215.  
    216.         _device=$($finddev)
    217.         [[ "$_device" == "error" ]] && _err "Physical disk $DISKNO not found in /etc/enclosure_0.conf"
    218.     else
    219.         _log "HDD $DISKNO: Device: /dev/${green}$_device${nc} Target: ${yellow}$RIGHT${nc}/$POOL"
    220.     fi
    221. }
    222.  
    223. # Let external disk go sleep...
    224. drive_remove() {
    225.     _device=$($finddev)
    226.     [[ "$_device" == "error" ]] && return 1
    227.     sync
    228.     sleep 5
    229.     hdparm -S 1 /dev/$_device
    230.     hdparm -y /dev/$_device
    231.  
    232.     umount /dev/$_device
    233.     echo offline > /sys/block/$_device/device/state
    234.     echo 1 > /sys/block/$_device/device/delete
    235.     return 0
    236. }
    237.  
    238. need ipkg
    239. ipkg update                  2>&1 >/dev/null
    240. ipkg install findutils       2>&1 >/dev/null
    241. ipkg install rsync           2>&1 >/dev/null
    242. ipkg install binutils        2>&1 >/dev/null
    243. ipkg install util-linux-ng   2>&1 >/dev/null
    244.  
    245. need rsync
    246. need ionice
    247. need find
    248.  
    249. DATE=`date +%Y-%m-%d` ;     TIME=`date +%H:%M:%S` ;     NOW=`date +%Y%m%d_%H%M%S`
    250.  
    251. # ###########################################################################
    252. # Basics
    253. # ###########################################################################
    254.  
    255. # find my name and real current directory
    256. # ###########################################################################
    257. PROGNAME=`type $0 | awk '{print $3}'`  # search for executable on path
    258.  
    259. PROGDIR=`dirname $PROGNAME`            # extract directory of program
    260. PROGNAME=`basename $PROGNAME`          # base name of program
    261.  
    262. [ "$PROGDIR" == "." ] && PROGDIR=`cd $PROGDIR && pwd || echo $PROGDIR`
    263.  
    264. Int_dPWD=`cd $PROGDIR && pwd || echo $PROGDIR`
    265. if [ "${Int_dPWD}" = "/etc/init.d" ] || [ "${Int_dPWD}" = "/etc/rcS.d" ] || [ "${Int_dPWD}" = "/etc/rcK.d" ]; then
    266.     [ -L "${PROGDIR}/${PROGNAME}" ] && {
    267.         _SLINK=$(readlink ${PROGDIR}/${PROGNAME})
    268.         PROGDIR=`dirname ${_SLINK}`
    269.         PROGNAME=`basename ${_SLINK}`
    270. }
    271. fi
    272.  
    273. # Fully qualify directory path (remove relative components and symlinks)
    274. # WARNING: The "bash" "pwd" builtin does not resolve symbolic links
    275. # "sh" (as a link to "bash") also does not,   but "csh" does handle it.
    276. # Symbolic link removal however is not critical.
    277. ORIGDIR=`pwd`                                 # original directory (builtin)
    278. PROGDIR=`cd $PROGDIR && pwd || echo $PROGDIR` # program directory
    279.  
    280. # Results...
    281. #    $ORIGDIR    -- where the users was when called
    282. #    $PROGDIR    -- script directory location (and now current directory)
    283. #    $PROGNAME   -- This scripts executable name
    284.  
    285.  
    286. # alternatively use this...
    287.  
    288. # Get the fully qualified path to the script
    289. # ###########################################################################
    290. case $0 in
    291.     /*)
    292.         SCRIPT="$0"
    293.         ;;
    294.     *)
    295.         PWD=`pwd`
    296.         SCRIPT="$PWD/$0"
    297.         ;;
    298. esac
    299.  
    300. # Change spaces to ":" so the tokens can be parsed.
    301. SCRIPT=`echo $SCRIPT | sed -e 's; ;:;g'`
    302. # Get the real path to this script, resolving any symbolic links
    303. TOKENS=`echo $SCRIPT | sed -e 's;/; ;g'`
    304. REALPATH=
    305. for C in $TOKENS; do
    306.     REALPATH="$REALPATH/$C"
    307.     while [ -h "$REALPATH" ] ; do
    308.         LS="`ls -ld "$REALPATH"`"
    309.         LINK="`expr "$LS" : '.*-> \(.*\)$'`"
    310.         if expr "$LINK" : '/.*' > /dev/null; then
    311.             REALPATH="$LINK"
    312.         else
    313.             REALPATH="`dirname "$REALPATH"`""/$LINK"
    314.         fi
    315.     done
    316. done
    317. # Change ":" chars back to spaces.
    318. REALPATH=`echo $REALPATH | sed -e 's;:; ;g'`
    319. REALPATH="`dirname "$REALPATH"`"
    320. [ "`basename $REALPATH`" == "." ] && \
    321.     REALPATH="`echo $REALPATH | awk '{$0=substr($0,1,length($0)-2); print $0}'`"
    322.  
    323. # Change the current directory to the location of the script
    324. PROGDIR="`cd $REALPATH && pwd || echo $PROGDIR`"
    325. cd "$PROGDIR"
    326.  
    327.  
    328. ##   LOG PATH
    329. MKBAKCONF="/share/Public/.makebackup"
    330. [[ -d "$MKBAKCONF" ]] || mkdir "$MKBAKCONF"
    331.  
    332. LOGDIR="$MKBAKCONF"
    333. LOGFILE="$LOGDIR/rsync_`date +%Y-%m-%d`.log"
    334.  
    335. SOURCES="$MKBAKCONF/backup.lst"
    336. if [ ! -f "$SOURCES" ]; then
    337.     echo -e "/share/Public/directory1\n/share/Multimedia/Family\n/etc\n..." > $SOURCES.example
    338.     _log "Create list file with source directories to backup: ${white}$SOURCES${nc}"
    339.     _err "Backup list not found $SOURCES"
    340.     exit 1
    341. fi
    342. LEFT=()
    343. s=0
    344. while read line; do
    345.     #LEFT[s]="$(echo -e "$line" | sed 's/ /\\ /g')"
    346.     LEFT[s]="$(echo -e "$line")"
    347.     s=$(expr $s + 1)
    348. done < "$SOURCES"
    349. echo -e "${bwhite}Source list${nc}: \n${LEFT[@]} \n"
    350.  
    351. CONFIG="$MKBAKCONF/backup.conf"
    352. [ -f "$CONFIG" ] || _err "Config file not found $CONFIG"
    353. RIGHT=$(getcfg Backup RIGHT -f "$CONFIG" -d error)
    354. echo -e "${bwhite}Remote path${nc}: \n$RIGHT     \n"
    355.  
    356. DISKNO=$(getcfg Backup DISKNO -f "$CONFIG" -d error)
    357. SPINDRIVE=$(getcfg Backup SPINDRIVE -f "$CONFIG" -d 0)
    358.  
    359. IGNORE="$MKBAKCONF/ignore.lst"
    360. [[ -f "$IGNORE" ]] || _err "Ignore list file not found $IGNORE"
    361.  
    362. [[ -d "$RIGHT" ]] || mkdir "$RIGHT"
    363. [[ -d "$RIGHT" ]] || _err "Destination directory path is wrong..."
    364.  
    365.  
    366.  
    367. # ###########################################################################
    368. # Global Variables
    369. # ###########################################################################
    370. # Time Measure Command
    371. STA_NOWTIME="date +%s"
    372.  
    373. ## func: Elapsed Time (calculate diff)
    374. ## ###########################################################################
    375. elapsedTime() {
    376.     local _startTime="$1"
    377.     local _endTime="$2"
    378.     echo "$(($_endTime - $_startTime))"
    379. }
    380.  
    381. #-----------------------------------------------------------------------
    382. # Private Signal Traps Functions {{{2
    383. #
    384. # DANGER: SIGKILL cannot be trapped. So, try not to `kill -9 PID` or
    385. #         there will be *NO CLEAN UP*. You'll have to manually remove
    386. #         any locks in place.
    387. #-----------------------------------------------------------------------
    388. function __make_locks {
    389.         if [ ! -e "${LOCK}" ] ; then
    390.                 touch "${LOCK}"
    391.         else
    392.                 _err application already started... Lock found ${LOCK}
    393.         fi
    394. }
    395.  
    396. function __clean_locks {
    397.         [ -f "$LOCK" ] && rm "$LOCK"
    398. }
    399. function __sig_exit {
    400.         __clean_locks
    401. }
    402.  
    403. function __sig_int {
    404.         echo -e "\n${warn} WARNING: ${nc} ${bred}SIGINT ${nc}${red}caught${nc}"
    405.         __clean_locks
    406.         exit 1002
    407. }
    408.  
    409. function __sig_quit {
    410.         echo -e "\n${bpurple} SIGQUIT ${nc}${purple}caught${nc}"
    411.         __clean_locks
    412.         exit 1003
    413. }
    414.  
    415. function __sig_term {
    416.         echo -e "\n${warn} WARNING: ${nc} ${bred}SIGTERM ${nc}${red}caught${nc}"
    417.         __clean_locks
    418.         exit 1015
    419. }
    420.  
    421. # Set TRAPs
    422. trap __sig_exit EXIT    # SIGEXIT
    423. #trap __sig_int INT      # SIGINT
    424. trap __sig_quit QUIT    # SIGQUIT
    425. trap __sig_term TERM    # SIGTERM
    426.  
    427. # Create lock file to prevent double run
    428. __make_locks
    429.  
    430. # Readd/remount disk drive
    431. [[ "$SPINDRIVE" == "1" ]] && drive_readd
    432.  
    433. # start time
    434. _startMeasureTime=$($STA_NOWTIME)
    435.  
    436. cd "$RIGHT" && \
    437. $PROGDIR/sayebackup.sh  \
    438.     --inc           \
    439.     --relative      \
    440.     -C "$RIGHT/"        \
    441.     -E "$IGNORE"        \
    442.     -o bak          \
    443.     "${LEFT[@]}"        \
    444.     | tee -a "$LOGFILE"
    445.  
    446. _RETVAL=${PIPESTATUS[0]}
    447. if [ $_RETVAL -eq 0 ]; then
    448.     _log "Sync done: -> $RIGHT"
    449. else
    450.     [ "$_QUIET" != "1" ] && _warn "error occured while rsync: -> $RIGHT"
    451.     RETVAL=1
    452. fi
    453.  
    454. # end time
    455. _endMeasureTime=$($STA_NOWTIME)
    456. _diffMeasure=$(elapsedTime $_startMeasureTime $_endMeasureTime)
    457. _log "Backup job done in $_diffMeasure seconds."
    458.  
    459. __clean_locks
    460.  
    461. # Force remove drive from OS/spin down
    462. if [ "$SPINDRIVE" == "1" ]; then
    463.     drive_remove
    464.     _RETVAL=$?
    465.     if [ $_RETVAL -eq 0 ]; then
    466.         _log "Disk disabled"
    467.     else
    468.         _warn "Failed while trying to disable disk drive"
    469.     fi
    470. fi
    471.  
    472. [ $RETVAL -ne 0 ] && _err "Errors occured."
    473. exit $RETVAL
    474.  
    475. # Parent process has died so we also better die.
    476. exit 0

    Rezultat
    Musze się pochwalić po jednym dniu działania skryptu.
    upload_2015-5-4_19-24-58.

    Docelowo ma wyłączać fizycznie dysk po wykonaniu kopii i ponownie go przywrócić... Ale... jeszcze nie jest to do końca zaimplementowane. Ale skrypt śmiało możecie używać jeśli cenicie sobie bezpieczeństwo danych.

    Brakuje regułki przywracającej wolumin:
    Kod (Bash):
    1. [~] # df
    2. Filesystem                Size      Used Available Use% Mounted on
    3. none                    200.0M    148.0M     52.0M  74% /
    4. devtmpfs                  1.9G      4.0k      1.9G   0% /dev
    5. tmpfs                    64.0M      3.6M     60.4M   6% /tmp
    6. tmpfs                     1.9G      4.0k      1.9G   0% /dev/shm
    7. /dev/md9                509.5M    108.2M    401.3M  21% /mnt/HDA_ROOT
    8. /dev/mapper/cachedev1     6.8T     28.2G      6.7T   0% /share/CACHEDEV1_DATA
    9. /dev/md13               371.0M    282.3M     88.7M  76% /mnt/ext
    10. /dev/mapper/cachedev2   909.0G     76.0M    908.5G   0% /share/CACHEDEV2_DATA
    11. [~] # umount /dev/mapper/cachedev2
    12. [~] # dmsetup remove cachedev2
    13. [~] # vgchange -an vg2
    14.   0 logical volume(s) in volume group "vg2" now active
    15. [~] # lvs
    16.   LV    VG   Attr     LSize   Pool Origin Data%  Move Log Copy%  Convert
    17.   lv1   vg1  Vwi-aot-   6.80t tp1         100.00
    18.   lv544 vg1  -wi-----  20.00g
    19.   tp1   vg1  twi-a-t-   7.22t              94.13
    20.   lv2   vg2  -wi----- 912.80g
    21.   lv545 vg2  -wi-----   9.22g
    22. [~] # mdadm -S /dev/md2
    23. mdadm: stopped /dev/md2
    24. [~] #
    25. [~] # echo 1 > /sys/block/sde/device/delete
    Kod (Bash):
    1. [~] # echo "0 0 0" > /sys/class/scsi_host/host3/scan
    2. [~] #
    3. [~] # storage_util --sys_startup_p2
    4. sys_startup_p2:got called count = 3
    5. Perform NAS model checking...
    6. NAS model match, skip model migration.
    7.  
    8. [~] # df
    9. Filesystem                Size      Used Available Use% Mounted on
    10. none                    200.0M    148.1M     51.9M  74% /
    11. devtmpfs                  1.9G      4.0k      1.9G   0% /dev
    12. tmpfs                    64.0M      3.6M     60.4M   6% /tmp
    13. tmpfs                     1.9G      4.0k      1.9G   0% /dev/shm
    14. /dev/md9                509.5M    108.2M    401.3M  21% /mnt/HDA_ROOT
    15. /dev/mapper/cachedev1     6.8T     28.2G      6.7T   0% /share/CACHEDEV1_DATA
    16. /dev/md13               371.0M    282.3M     88.7M  76% /mnt/ext
    17. /dev/mapper/cachedev2   909.0G     76.0M    908.5G   0% /share/CACHEDEV2_DATA
     
    • Piwo Piwo x 2
    • Lubię to! Lubię to! x 1
  2. Silas Mariusz
    Offline

    Silas Mariusz SysOp Administrator

    Dołączył:
    5 Kwiecień 2008
    Wiadomości:
    6 033
    Miejscowość:
    Nowy Sącz
    Local Time:
    12:39
    Oceny:
    +1 340 / 30 / -5
    Followers:
    22
    QNAP:
    TVS-x71
    Ethernet:
    1 GbE
    TVS-x71 1 GbE
    TODO:
     

Poleć tę stronę