Просмотр исходного кода

backup restoration 90% completed

Serghey Rodin 13 лет назад
Родитель
Сommit
65db51189c

+ 18 - 12
bin/v-backup-user

@@ -402,7 +402,7 @@ then
     cron_record=$(wc -l $USER_DATA/cron.conf|cut -f 1 -d ' ')
 
     if [ -e "/var/spool/cron/$user" ]; then
-        cron_list='yes'
+        cron_list="$cron_record"
         cp /var/spool/cron/$user $tmpdir/cron/
     fi
     if [ "$cron_record" -eq 1 ]; then
@@ -417,22 +417,28 @@ then
 fi
 
 # User Directories
-echo "-- User Directories --"
-msg="$msg\n-- User Directories --"
-mkdir $tmpdir/user_dirs
-user_dirs=$(ls $HOMEDIR/$user | \
+echo "-- User Dir --"
+msg="$msg\n-- User Dir --"
+mkdir $tmpdir/user_dir
+user_dir=$(ls $HOMEDIR/$user | \
     grep -v conf | \
     grep -v web | \
     grep -v dns | \
     grep -v mail | \
     grep -v tmp)
 i=0
-for user_dir in $user_dirs; do
+for udir in $user_dir; do
+    udir_list="$udir_list $udir"
     ((i ++))
-    echo -e "$(date "+%F %T") $user_dir"
-    msg="$msg\n$(date "+%F %T") $user_dir"
-    cp -pr $HOMEDIR/$user/$user_dir $tmpdir/user_dirs/
+    echo -e "$(date "+%F %T") $udir"
+    msg="$msg\n$(date "+%F %T") $udir"
+    cp -pr $HOMEDIR/$user/$udir $tmpdir/user_dir/
+    cd $tmpdir/user_dir/
+    tar -czpf $udir.tar.gz $udir
+    rm -rf $udir
 done
+udir_list=$(echo "$udir_list" | sed -e "s/  */\ /g" -e "s/^ //")
+
 if [ "$i" -eq 1 ]; then
     echo -e "$(date "+%F %T") $i user directory"
     msg="$msg\n$(date "+%F %T") $i directory"
@@ -508,7 +514,7 @@ local_backup(){
 
 # Defining ftp command function
 ftpc() {
-    ftp -n $HOST $FTP_PORT <<EOF
+    ftp -n $HOST <<EOF
     quote USER $USERNAME
     quote PASS $PASSWORD
     binary
@@ -648,18 +654,18 @@ done
 # Concatenating string
 backup_str="BACKUP='$user.$DATE.tar'"
 backup_str="$backup_str TYPE='$BACKUP_SYSTEM' SIZE='$size'"
-backup_str="$backup_str VESTA='yes'"
 backup_str="$backup_str WEB='${web_list// /,}'"
 backup_str="$backup_str DNS='${dns_list// /,}'"
 backup_str="$backup_str MAIL='${mail_list// /,}'"
 backup_str="$backup_str DB='${db_list// /,}'"
 backup_str="$backup_str CRON='$cron_list'"
+backup_str="$backup_str UDIR='${udir_list// /,}'"
 backup_str="$backup_str RUNTIME='$run_time' TIME='$TIME' DATE='$DATE'"
 echo "$backup_str" >> $USER_DATA/backup.conf
 chmod 660 $USER_DATA/backup.conf
 
 # Clean backup queue
-sed -i "/ $user /d" $VESTA/data/queue/backup.pipe
+sed -i "/v-backup-user $user /d" $VESTA/data/queue/backup.pipe
 
 # Send notification
 if [ "$notify" != 'no' ]; then

+ 2 - 2
bin/v-list-user-backup

@@ -88,8 +88,8 @@ is_object_valid 'backup' 'BACKUP' "$backup"
 # Defining config and fields to select
 conf=$USER_DATA/backup.conf
 
-fields="\$BACKUP \$TYPE \$SIZE \$VESTA \$PAM \$WEB \$DNS \$DB"
-fields="$fields \$MAIL \$CRON \$RUNTIME \$TIME \$DATE"
+fields="\$BACKUP \$TYPE \$SIZE \$WEB \$DNS \$DB \$MAIL \$CRON \$UDIR"
+fields="$fields \$RUNTIME \$TIME \$DATE"
 
 # Listing backup
 case $format in 

+ 2 - 2
bin/v-list-user-backups

@@ -36,8 +36,8 @@ if [ ! -e "$conf" ]; then
 fi
 
 # Defining fileds to select
-fields="\$BACKUP \$TYPE \$SIZE \$VESTA \$PAM \$WEB \$DNS \$DB"
-fields="$fields \$MAIL \$CRON \$RUNTIME \$TIME \$DATE"
+fields="\$BACKUP \$TYPE \$SIZE \$WEB \$DNS \$DB \$MAIL \$CRON \$UDIR"
+fields="$fields \$RUNTIME \$TIME \$DATE"
 
 # Listing domains
 case $format in 

+ 63 - 4
bin/v-restore-user

@@ -1,6 +1,6 @@
 #!/bin/bash
 # info: restore user
-# options: USER BACKUP [WEB] [DNS] [MAIL] [DB] [CRON] [UDIRS] [NOTIFY]
+# options: USER BACKUP [WEB] [DNS] [MAIL] [DB] [CRON] [UDIR] [NOTIFY]
 #
 # The function for resotring user from backup.
 
@@ -17,7 +17,7 @@ dns=$4
 mail=$5
 db=$6
 cron=$7
-u_dirs=$8
+udir=$8
 notify=${9-no}
 
 # Define backup dir
@@ -47,7 +47,7 @@ is_backup_valid() {
 #                    Verifications                         #
 #----------------------------------------------------------#
 
-args='USER BACKUP [WEB] [DNS] [MAIL] [DB] [CRON] [UDIRS] [NOTIFY]'
+args='USER BACKUP [WEB] [DNS] [MAIL] [DB] [CRON] [UDIR] [NOTIFY]'
 check_args '2' "$#" $args
 validate_format 'user' 'backup'
 is_object_valid 'user' 'USER' "$user"
@@ -574,7 +574,7 @@ if [ "$cron" != 'no' ]; then
     echo -e "$(date "+%F %T") $db"
     msg="$msg\n$(date "+%F %T") $db"
 
-    # unpack db container
+    # unpack cron container
     tar xf $BACKUP/$backup -C $tmpdir ./cron
     if [ "$?" -ne 0 ]; then
         echo "Error: can't unpack cron contaner"
@@ -593,9 +593,68 @@ if [ "$cron" != 'no' ]; then
     msg="$msg\n"
 fi
 
+# Restore user directories
+if [ "$udir" != 'no' ]; then
+    echo "-- USER DIR --"
+    msg="$msg\n-- USER DIR --"
+
+    # unpack user dir container
+    if [ ! -z "$(tar -tf $BACKUP/$backup |grep './user_dir')" ]; then
+
+        # Create user dir list
+        udir_list=$(tar -tf $BACKUP/$backup | grep "^./user_dir" |\
+            grep tar.gz | cut -f 3 -d '/' | sed -e "s/.tar.gz//")
+
+        if [ ! -z "$udir" ]; then
+            udir_include_list=$(mktemp)
+            for udir_include in ${udir//,/ }; do
+                echo "^$udir_include$" >> $udir_include_list
+            done
+            udir_list=$(echo "$udir_list" | egrep -f $udir_include_list )
+            rm -f $udir_include_list
+        fi
+
+        for user_dir in $udir_list; do
+            echo -e "$(date "+%F %T") $user_dir"
+            msg="$msg\n$(date "+%F %T") $user_dir"
+
+            # unpack user_dir container
+            tar xf $BACKUP/$backup -C $tmpdir ./user_dir/$user_dir.tar.gz
+            if [ "$?" -ne 0 ]; then
+                echo "Error: can't unpack $user_dir user dir contaner"
+                echo "Can't unpack $user_dir user dir contaner" |\
+                    $send_mail -s "$subj" $email
+                rm -rf $tmpdir
+                exit $E_PARSING
+            fi
+
+            tar xzf $tmpdir/user_dir/$user_dir.tar.gz -C $HOMEDIR/$user
+            if [ "$?" -ne 0 ]; then
+                echo "Error: can't unpack $user_dir user dir contaner"
+                echo "Can't unpack $user_dir user dir contaner" |\
+                    $send_mail -s "$subj" $email
+                rm -rf $tmpdir
+                exit $E_PARSING
+            fi
+        done
+    fi
+    echo
+    msg="$msg\n"
+fi
+
 # Remove temporary data
 rm -rf $tmpdir
 
+# Clean restore queue
+sed -i "/v-restore-user $user /d" $VESTA/data/queue/backup.pipe
+
+# Send notification
+if [ "$notify" != 'no' ]; then
+    subj="$user → restore has been completed"
+    email=$(get_user_value '$CONTACT')
+    echo -e "$msg" | $send_mail -s "$subj" $email
+fi
+
 
 #----------------------------------------------------------#
 #                       Vesta                              #

+ 2 - 2
bin/v-add-user-backup → bin/v-schedule-user-backup

@@ -26,14 +26,14 @@ validate_format 'user'
 is_system_enabled "$BACKUP_SYSTEM"
 is_object_valid 'user' 'USER' "$user"
 is_backup_enabled
-is_backup_scheduled
+is_backup_scheduled 'backup'
 
 
 #----------------------------------------------------------#
 #                       Action                             #
 #----------------------------------------------------------#
 
-# Adding backup to pipe
+# Adding backup task to  the queue
 echo "$BIN/v-backup-user $user yes" >> $VESTA/data/queue/backup.pipe
 
 

+ 56 - 0
bin/v-schedule-user-restore

@@ -0,0 +1,56 @@
+#!/bin/bash
+# info: schedule user backup restoration
+# options: USER BACKUP [WEB] [DNS] [MAIL] [DB] [CRON] [UDIR]
+#
+# The function for scheduling user backup restoration.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+backup=$2
+web=$3
+dns=$4
+mail=$5
+db=$6
+cron=$7
+udir=$8
+
+# Includes
+source $VESTA/conf/vesta.conf
+source $VESTA/func/main.sh
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '2' "$#" 'USER BACKUP [WEB] [DNS] [MAIL] [DB] [CRON] [UDIR]'
+validate_format 'user'
+is_system_enabled "$BACKUP_SYSTEM"
+is_object_valid 'user' 'USER' "$user"
+is_backup_enabled
+is_backup_scheduled 'restore'
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Adding restore task to  the queue
+options="'$web' '$dns' '$mail' '$db' '$cron' '$udir'"
+echo "$BIN/v-restore-user $user $backup $options  yes" \
+    >> $VESTA/data/queue/backup.pipe
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Logging
+log_event "$OK" "$EVENT"
+
+exit

+ 3 - 3
func/main.sh

@@ -161,9 +161,9 @@ is_backup_enabled() {
 # Check user backup settings
 is_backup_scheduled() {
     if [ -e "$VESTA/data/queue/backup.pipe" ]; then
-        check_backup=$(grep " $user " $VESTA/data/queue/backup.pipe)
-        if [ ! -z "$check_backup" ]; then
-            echo "Error: backup is already scheduled"
+        check_q=$(grep " $user " $VESTA/data/queue/backup.pipe | grep $1)
+        if [ ! -z "$check_q" ]; then
+            echo "Error: $1 is already scheduled"
             log_event "$E_EXISTS" "$EVENT"
             exit $E_EXISTS
         fi

+ 41 - 0
web/bulk/restore/index.php

@@ -0,0 +1,41 @@
+<?php
+// Init
+error_reporting(NULL);
+ob_start();
+session_start();
+
+include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
+
+$action = $_POST['action'];
+$backup = escapeshellarg($_POST['backup']);
+
+$web = 'no';
+$dns = 'no';
+$mail = 'no';
+$db = 'no';
+$cron = 'no';
+$udir = 'no';
+
+if (!empty($_POST['web'])) $web = escapeshellarg(implode(",",$_POST['web']));
+if (!empty($_POST['dns'])) $dns = escapeshellarg(implode(",",$_POST['dns']));
+if (!empty($_POST['mail'])) $mail = escapeshellarg(implode(",",$_POST['mail']));
+if (!empty($_POST['db'])) $db = escapeshellarg(implode(",",$_POST['db']));
+if (!empty($_POST['cron'])) $cron = 'yes';
+if (!empty($_POST['udir'])) $udir = escapeshellarg(implode(",",$_POST['udir']));
+
+if ($action == 'restore') {
+    exec (VESTA_CMD."v-schedule-user-restore ".$user." ".$backup." ".$web." ".$dns." ".$mail." ".$db." ".$cron." ".$udir, $output, $return_var);
+    if ($return_var == 0) {
+        $_SESSION['restore_msg'] = _('RESTORE_SCHEDULED');
+    } else {
+        $_SESSION['restore_msg'] = implode('<br>', $output);
+        if (empty($_SESSION['restore_msg'])) {
+            $_SESSION['restore_msg'] = _('Error: vesta did not return any output.');
+        }
+        if ($return_var == 4) {
+            $_SESSION['restore_msg'] = _('RESTORE_EXISTS');
+        }
+    }
+}
+
+header("Location: /list/backup/?backup=" . $_POST['backup']);

+ 3 - 0
web/inc/i18n/en.php

@@ -367,6 +367,9 @@ $LANG['en'] = array(
     'IP address is in use' => 'IP address is in use',
     'BACKUP_SCHEDULED'  => 'Task has been added to the queue. You will receive an email notification when your backup is ready for download.',
     'BACKUP_EXISTS'  => 'An existing backup is already running. Please wait for that backup to finish.',
+    'RESTORE_SCHEDULED'  => 'Task has been added to the queue. You will receive an email notification when your backup is ready for download.',
+    'RESTORE_EXISTS'  => 'An existing restoration task is already running. Please wait for it to finish before launching it again.',
+
 
     'Welcome to Vesta Control Panel'  => 'Welcome to Vesta Control Panel',
     'MAIL_FROM'  => 'Vesta Control Panel <noreply@%s>',

+ 2 - 0
web/inc/i18n/es.php

@@ -366,6 +366,8 @@ $LANG['es'] = array(
     'IP address is in use' => 'La IP esta en uso',
     'BACKUP_SCHEDULED'  => "La tarea se ha añadido a la cola. Usted recibirá un correo de notificación cuando el respaldo de seguridad este listo para su descarga.",
     'BACKUP_EXISTS'  => "Se esta realizando una copia de seguridad en este momento.Por favor espere a que esta termine.",
+    'RESTORE_SCHEDULED'  => "La tarea se ha añadido a la cola. Usted recibirá un correo de notificación cuando el respaldo de seguridad este listo para su descarga.",
+    'RESTORE_EXISTS'  => "Una tarea se está ejecutando. Por favor espere a que esta termine.",
 
     'Welcome to Vesta Control Panel'  => 'Bienvenido al Panel de Control Vesta',
     'MAIL_FROM'  => 'Panel de Control Vesta <noreply@%s>',

+ 2 - 0
web/inc/i18n/ru.php

@@ -368,6 +368,8 @@ $LANG['ru'] = array(
     'IP address is in use' => 'IP адрес используется',
     'BACKUP_SCHEDULED'  => 'Задание успешно добавлено в очередь. После завершения вы получите полный отчет по почте.',
     'BACKUP_EXISTS'  => 'Резервное копирование уже выполняется, полжалуйста дождитесь окончания.',
+    'RESTORE_SCHEDULED'  => 'Задание успешно добавлено в очередь. После завершения вы получите полный отчет по почте.',
+    'RESTORE_EXISTS'  => 'Задание уже выполняется, полжалуйста дождитесь окончания.',
 
     'Welcome to Vesta Control Panel' => 'Добро пожаловать в панель управления Vesta',
     'MAIL_FROM' => 'Vesta Control Panel <noreply@%s>',

+ 2 - 0
web/inc/i18n/ua.php

@@ -368,6 +368,8 @@ $LANG['ua'] = array(
     'IP address is in use' => 'IP адреса використовується',
     'BACKUP_SCHEDULED'  => 'Завдання успішно додано в чергу. Після завершення ви отримаєте повний звіт по пошті.',
     'BACKUP_EXISTS'  => 'Резервне копіювання вже виконується, будь-ласка дочекайтесь закінчення.',
+    'RESTORE_SCHEDULED'  => 'Завдання успішно додано в чергу. Після завершення ви отримаєте повний звіт по пошті.',
+    'RESTORE_EXISTS'  => 'Завдання вже виконується, будь-ласка дочекайтесь закінчення.',
  
     'Welcome to Vesta Control Panel' => 'Вітаємо в панелі керування Vesta',
     'MAIL_FROM' => 'Vesta Control Panel <noreply@%s>',

+ 1 - 1
web/add/backup/index.php → web/schedule/backup/index.php

@@ -6,7 +6,7 @@ session_start();
 include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
 
 $v_username = escapeshellarg($user);
-exec (VESTA_CMD."v-add-user-backup ".$v_username, $output, $return_var);
+exec (VESTA_CMD."v-schedule-user-backup ".$v_username, $output, $return_var);
 if ($return_var == 0) {
     $_SESSION['backup_msg'] = _('BACKUP_SCHEDULED');
 } else {

+ 40 - 0
web/schedule/restore/index.php

@@ -0,0 +1,40 @@
+<?php
+// Init
+error_reporting(NULL);
+ob_start();
+session_start();
+
+include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
+
+$backup = escapeshellarg($_GET['backup']);
+
+$web = 'no';
+$dns = 'no';
+$mail = 'no';
+$db = 'no';
+$cron = 'no';
+$udir = 'no';
+
+if ($_GET['type'] == 'web') $web = escapeshellarg($_GET['object']);
+if ($_GET['type'] == 'dns') $dns = escapeshellarg($_GET['object']);
+if ($_GET['type'] == 'mail') $mail = escapeshellarg($_GET['object']);
+if ($_GET['type'] == 'db') $db = escapeshellarg($_GET['object']);
+if ($_GET['type'] == 'cron') $cron = 'yes';
+if ($_GET['type'] == 'udir') $udir = escapeshellarg($_GET['object']);
+
+if (!empty($_GET['type'])) {
+    exec (VESTA_CMD."v-schedule-user-restore ".$user." ".$backup." ".$web." ".$dns." ".$mail." ".$db." ".$cron." ".$udir, $output, $return_var);
+    if ($return_var == 0) {
+        $_SESSION['restore_msg'] = _('RESTORE_SCHEDULED');
+    } else {
+        $_SESSION['restore_msg'] = implode('<br>', $output);
+        if (empty($_SESSION['restore_msg'])) {
+            $_SESSION['restore_msg'] = _('Error: vesta did not return any output.');
+        }
+        if ($return_var == 4) {
+            $_SESSION['restore_msg'] = _('RESTORE_EXISTS');
+        }
+    }
+}
+
+header("Location: /list/backup/?backup=" . $_GET['backup']);

+ 26 - 20
web/templates/admin/list_backup.html

@@ -2,7 +2,7 @@
                                     <tr>
                                         <td style="padding: 2px 0 0 6px">
                                             <div class="submenu-button-block">
-                                                <button class="submenu-button" onclick="location.href='/add/backup/'"> <?php print _('Create Backup');?> </button>
+                                                <button class="submenu-button" onclick="location.href='/schedule/backup/'"> <?php print _('Create Backup');?> </button>
                                             </div>
                                             <div class="submenu-search-block">
                                                 <form action="/search/" method="get">
@@ -14,8 +14,8 @@
                                                 <form action="/bulk/backup/" method="post" id="objects">
                                                 <a class="submenu-select-link" href='javascript:checkedAll("objects");'> <?php print _('toggle all');?> </a>
                                                 <select class="submenu-select-dropdown" name="action">
-                                                    <option><?php print _('apply to selected');?></option>
-                                                    <option><?php print _('delete');?></option>
+                                                    <option value=""><?php print _('apply to selected');?></option>
+                                                    <option value="delete"><?php print _('delete');?></option>
                                                 </select>
                                                 <input type="submit" name="ok" value="›" class="submenu-button" style="width: 36px;">
                                             </div>
@@ -61,11 +61,16 @@
                                     $dns = _('no');
                                     $mail = _('no');
                                     $db = _('no');
+                                    $cron = _('no');
+                                    $udir = _('no');
 
                                     if (!empty($data[$key]['WEB'])) $web = _('yes').' ¨';
                                     if (!empty($data[$key]['DNS'])) $dns = _('yes').' ¨';
                                     if (!empty($data[$key]['MAIL'])) $mail = _('yes').' ¨';
                                     if (!empty($data[$key]['DB'])) $db = _('yes').' ¨';
+                                    if (!empty($data[$key]['CRON'])) $cron = _('yes').' ¨';
+                                    if (!empty($data[$key]['UDIR'])) $udir = _('yes').' ¨';
+
                             ?> 
 
                             <tr class="data-row">
@@ -127,16 +132,6 @@
                                             </td>
                                             <td style="vertical-align:top;" width="250">
                                                 <table>
-                                                    <tr>
-                                                        <td class="counter-name" width="48">
-                                                            <?php print _('SYS');?>:
-                                                        </td>
-                                                        <td>
-                                                            <a class="counter-value" title="<?php echo $data[$key]['VESTA'] ?>">
-                                                                <?php echo _($data[$key]['VESTA']) ?> 
-                                                            </a>
-                                                        </td>
-                                                    </tr>
                                                     <tr>
                                                         <td class="counter-name" width="48">
                                                             <?php print _('WEB');?>:
@@ -157,10 +152,6 @@
                                                             </a>
                                                         </td>
                                                     </tr>
-                                                </table>
-                                            </td>
-                                            <td rowspan=4 style="vertical-align:top;" width="300">
-                                                <table>
                                                     <tr>
                                                         <td class="counter-name" width="48">
                                                             <?php print _('MAIL');?>:
@@ -171,8 +162,12 @@
                                                             </a>
                                                         </td>
                                                     </tr>
+                                                </table>
+                                            </td>
+                                            <td rowspan=4 style="vertical-align:top;" width="300">
+                                                <table>
                                                     <tr>
-                                                        <td class="counter-name" width="48">
+                                                        <td class="counter-name" width="90">
                                                             <?php print _('DB');?>:
                                                         </td>
                                                         <td>
@@ -182,15 +177,26 @@
                                                         </td>
                                                     </tr>
                                                     <tr>
-                                                        <td class="counter-name" width="48">
+                                                        <td class="counter-name" width="90">
                                                             <?php print _('CRON');?>:
                                                         </td>
                                                         <td>
                                                             <a class="counter-value" title="<?php echo $data[$key]['CRON'] ?>">
-                                                                <?php echo _($data[$key]['CRON']) ?> 
+                                                                <?php echo $cron ?> 
+                                                            </a>
+                                                        </td>
+                                                    </tr>
+                                                    <tr>
+                                                        <td class="counter-name" width="90">
+                                                            <?php print _('USER DIRS');?>:
+                                                        </td>
+                                                        <td>
+                                                            <a class="counter-value" title="<?php echo str_replace(',', ', ', $data[$key]['UDIR']) ?>">
+                                                                <?php echo $udir ?> 
                                                             </a>
                                                         </td>
                                                     </tr>
+
                                                 </table>
                                             </td>
                                         </tr>

+ 54 - 40
web/templates/admin/list_backup_detail.html

@@ -2,7 +2,7 @@
                                     <tr>
                                         <td style="padding: 2px 0 0 6px">
                                             <div class="submenu-button-block">
-                                                <button class="submenu-button" onclick="location.href='/add/backup/'"> <?php print _('Restore All');?> </button>
+                                                <button class="submenu-button" onclick="location.href='/schedule/restore/'"> <?php print _('Restore All');?> </button>
                                             </div>
                                             <div class="submenu-search-block">
                                                 <form action="/search/" method="get">
@@ -11,16 +11,17 @@
                                                 </form>
                                             </div>
                                             <div class="submenu-select-block">
-                                                <form action="/bulk/backup/" method="post" id="objects">
+                                                <form action="/bulk/restore/" method="post" id="objects">
                                                 <a class="submenu-select-link" href='javascript:checkedAll("objects");'> <?php print _('toggle all');?> </a>
                                                 <select class="submenu-select-dropdown" name="action">
-                                                    <option><?php print _('apply to selected');?></option>
-                                                    <option><?php print _('delete');?></option>
+                                                    <option value=""><?php print _('apply to selected');?></option>
+                                                    <option value="restore"><?php print _('restore');?></option>
                                                 </select>
+                                                <input type="hidden" name="backup" value="<?php echo $_GET['backup'] ?>">
                                                 <input type="submit" name="ok" value="›" class="submenu-button" style="width: 36px;">
                                             </div>
                                             <?php
-                                                if (!empty($_SESSION['backup_msg'])) {
+                                                if (!empty($_SESSION['restore_msg'])) {
                                             ?>
                                             <div>
                                                 <script type="text/javascript">
@@ -37,11 +38,11 @@
                                                     });
                                                 </script>
                                                 <div id="dialog-message" title="<?php print _('Backup System') ?>">
-                                                    <p><?php echo $_SESSION['backup_msg'] ?></p>
+                                                    <p><?php echo $_SESSION['restore_msg'] ?></p>
                                                 </div>
                                             </div>
                                             <?php
-                                                    unset($_SESSION['backup_msg']);
+                                                    unset($_SESSION['restore_msg']);
                                                 }
                                             ?>
                                         </td>
@@ -63,19 +64,22 @@
                         <div style="height:10px; font-size:0;"></div>
                         <table class="data">
 
+
                             <?php
                                 $backup = $_GET['backup'];
-                                if (!empty($data[$backup]['VESTA'])) {
+                                $web = explode(',',$data[$backup]['WEB']);
+                                foreach ($web as $key) {
+                                    if (!empty($key)) {
                             ?> 
 
                             <tr class="data-row">
                                 <td class="data-dotted" style="padding: 0px 10px 0px 0px" width="150">
                                     <table class="data-col1">
-                                        <tr><td style="padding: 18 0 4 18;"><input type="checkbox" name="backup[]" value="<?php echo $key ?>" ></td></tr>
+                                        <tr><td style="padding: 18 0 4 18;"><input type="checkbox" name="web[]" value="<?php echo $key ?>" ></td></tr>
                                     </table>
                                 </td>
                                 <td class="data-dotted" width="830px" style="vertical-align:top;">
-                                    <a href="#" id="restore_link_<?php echo "$i"?>" class="data-controls">
+                                    <a href="/schedule/restore/?backup=<?php echo $backup ?>&type=web&object=<?php echo $key ?>" class="data-controls">
                                         <span>
                                             <img src="/images/restore.png" width="6px" height="8px">
                                             <?php print _('restore');?> 
@@ -84,10 +88,10 @@
                                     <table class="data-col2" width="830px">
                                         <tr>
                                             <td class="cron" style="width: 170px; font-size: 14px;">
-                                                <?php echo _('sys') ?>
+                                                <?php echo 'web ' . _('domain') ?> 
                                             </td>
                                             <td class="domain" style="padding: 0 0 0 4px;">
-                                                <b><?php echo _('user data') ?></b>
+                                                <b><?php echo $key ?></b>
                                             </td>
                                         </tr>
                                     </table>
@@ -95,23 +99,24 @@
                             </tr>
 
                             <?php
+                                    }
                                 }
                             ?> 
 
-
                             <?php
-                                $web = explode(',',$data[$backup]['WEB']);
-                                foreach ($web as $key) {
+                                $dns = explode(',',$data[$backup]['DNS']);
+                                foreach ($dns as $key) {
+                                    if (!empty($key)) {
                             ?> 
 
                             <tr class="data-row">
                                 <td class="data-dotted" style="padding: 0px 10px 0px 0px" width="150">
                                     <table class="data-col1">
-                                        <tr><td style="padding: 18 0 4 18;"><input type="checkbox" name="backup[]" value="<?php echo $key ?>" ></td></tr>
+                                        <tr><td style="padding: 18 0 4 18;"><input type="checkbox" name="dns[]" value="<?php echo $key ?>" ></td></tr>
                                     </table>
                                 </td>
                                 <td class="data-dotted" width="830px" style="vertical-align:top;">
-                                    <a href="#" id="restore_link_<?php echo "$i"?>" class="data-controls">
+                                    <a href="/schedule/restore/?backup=<?php echo $backup ?>&type=dns&object=<?php echo $key ?>" class="data-controls">
                                         <span>
                                             <img src="/images/restore.png" width="6px" height="8px">
                                             <?php print _('restore');?> 
@@ -120,7 +125,7 @@
                                     <table class="data-col2" width="830px">
                                         <tr>
                                             <td class="cron" style="width: 170px; font-size: 14px;">
-                                                <?php echo 'web ' . _('domain') ?>
+                                                <?php echo 'dns ' . _('domain') ?>
                                             </td>
                                             <td class="domain" style="padding: 0 0 0 4px;">
                                                 <b><?php echo $key ?></b>
@@ -131,22 +136,24 @@
                             </tr>
 
                             <?php
+                                    }
                                 }
                             ?> 
 
                             <?php
-                                $dns = explode(',',$data[$backup]['DNS']);
-                                foreach ($dns as $key) {
+                                $mail = explode(',',$data[$backup]['MAIL']);
+                                foreach ($mail as $key) {
+                                    if (!empty($key)) {
                             ?> 
 
                             <tr class="data-row">
                                 <td class="data-dotted" style="padding: 0px 10px 0px 0px" width="150">
                                     <table class="data-col1">
-                                        <tr><td style="padding: 18 0 4 18;"><input type="checkbox" name="backup[]" value="<?php echo $key ?>" ></td></tr>
+                                        <tr><td style="padding: 18 0 4 18;"><input type="checkbox" name="mail[]" value="<?php echo $key ?>" ></td></tr>
                                     </table>
                                 </td>
                                 <td class="data-dotted" width="830px" style="vertical-align:top;">
-                                    <a href="#" id="restore_link_<?php echo "$i"?>" class="data-controls">
+                                    <a href="/schedule/restore/?backup=<?php echo $backup ?>&type=mail&object=<?php echo $key ?>" class="data-controls">
                                         <span>
                                             <img src="/images/restore.png" width="6px" height="8px">
                                             <?php print _('restore');?> 
@@ -155,7 +162,7 @@
                                     <table class="data-col2" width="830px">
                                         <tr>
                                             <td class="cron" style="width: 170px; font-size: 14px;">
-                                                <?php echo 'dns ' . _('domain') ?>
+                                                <?php echo 'mail ' . _('domain') ?>
                                             </td>
                                             <td class="domain" style="padding: 0 0 0 4px;">
                                                 <b><?php echo $key ?></b>
@@ -166,22 +173,24 @@
                             </tr>
 
                             <?php
+                                    }
                                 }
                             ?> 
 
                             <?php
-                                $mail = explode(',',$data[$backup]['MAIL']);
-                                foreach ($mail as $key) {
+                                $db = explode(',',$data[$backup]['DB']);
+                                foreach ($db as $key) {
+                                    if (!empty($key)) {
                             ?> 
 
                             <tr class="data-row">
                                 <td class="data-dotted" style="padding: 0px 10px 0px 0px" width="150">
                                     <table class="data-col1">
-                                        <tr><td style="padding: 18 0 4 18;"><input type="checkbox" name="backup[]" value="<?php echo $key ?>" ></td></tr>
+                                        <tr><td style="padding: 18 0 4 18;"><input type="checkbox" name="db[]" value="<?php echo $key ?>" ></td></tr>
                                     </table>
                                 </td>
                                 <td class="data-dotted" width="830px" style="vertical-align:top;">
-                                    <a href="#" id="restore_link_<?php echo "$i"?>" class="data-controls">
+                                    <a href="/schedule/restore/?backup=<?php echo $backup ?>&type=db&object=<?php echo $key ?>" class="data-controls">
                                         <span>
                                             <img src="/images/restore.png" width="6px" height="8px">
                                             <?php print _('restore');?> 
@@ -190,7 +199,7 @@
                                     <table class="data-col2" width="830px">
                                         <tr>
                                             <td class="cron" style="width: 170px; font-size: 14px;">
-                                                <?php echo 'mail ' . _('domain') ?>
+                                                <?php echo _('database') ?>
                                             </td>
                                             <td class="domain" style="padding: 0 0 0 4px;">
                                                 <b><?php echo $key ?></b>
@@ -201,22 +210,24 @@
                             </tr>
 
                             <?php
+                                    }
                                 }
                             ?> 
 
                             <?php
-                                $db = explode(',',$data[$backup]['DB']);
-                                foreach ($db as $key) {
+                                $backup = $_GET['backup'];
+                                if (!empty($data[$backup]['CRON'])) {
+                                    if (!empty($key)) {
                             ?> 
 
                             <tr class="data-row">
                                 <td class="data-dotted" style="padding: 0px 10px 0px 0px" width="150">
                                     <table class="data-col1">
-                                        <tr><td style="padding: 18 0 4 18;"><input type="checkbox" name="backup[]" value="<?php echo $key ?>" ></td></tr>
+                                        <tr><td style="padding: 18 0 4 18;"><input type="checkbox" name="cron[]" value="<?php echo 'yes' ?>" ></td></tr>
                                     </table>
                                 </td>
                                 <td class="data-dotted" width="830px" style="vertical-align:top;">
-                                    <a href="#" id="restore_link_<?php echo "$i"?>" class="data-controls">
+                                    <a href="/schedule/restore/?backup=<?php echo $backup ?>&type=cron&object=records" class="data-controls">
                                         <span>
                                             <img src="/images/restore.png" width="6px" height="8px">
                                             <?php print _('restore');?> 
@@ -225,10 +236,10 @@
                                     <table class="data-col2" width="830px">
                                         <tr>
                                             <td class="cron" style="width: 170px; font-size: 14px;">
-                                                <?php echo _('database') ?>
+                                                <?php echo _('cron') ?>
                                             </td>
                                             <td class="domain" style="padding: 0 0 0 4px;">
-                                                <b><?php echo $key ?></b>
+                                                <b><?php echo 'cron ' . _('records') ?></b>
                                             </td>
                                         </tr>
                                     </table>
@@ -236,22 +247,24 @@
                             </tr>
 
                             <?php
+                                    }
                                 }
                             ?> 
 
                             <?php
-                                $backup = $_GET['backup'];
-                                if (!empty($data[$backup]['CRON'])) {
+                                $udir = explode(',',$data[$backup]['UDIR']);
+                                foreach ($udir as $key) {
+                                    if (!empty($key)) {
                             ?> 
 
                             <tr class="data-row">
                                 <td class="data-dotted" style="padding: 0px 10px 0px 0px" width="150">
                                     <table class="data-col1">
-                                        <tr><td style="padding: 18 0 4 18;"><input type="checkbox" name="backup[]" value="<?php echo $key ?>" ></td></tr>
+                                        <tr><td style="padding: 18 0 4 18;"><input type="checkbox" name="udir[]" value="<?php echo $key ?>" ></td></tr>
                                     </table>
                                 </td>
                                 <td class="data-dotted" width="830px" style="vertical-align:top;">
-                                    <a href="#" id="restore_link_<?php echo "$i"?>" class="data-controls">
+                                    <a href="/schedule/restore/?backup=<?php echo $backup ?>&type=udir&object=<?php echo $key ?>" class="data-controls">
                                         <span>
                                             <img src="/images/restore.png" width="6px" height="8px">
                                             <?php print _('restore');?> 
@@ -260,10 +273,10 @@
                                     <table class="data-col2" width="830px">
                                         <tr>
                                             <td class="cron" style="width: 170px; font-size: 14px;">
-                                                <?php echo _('cron') ?>
+                                                <?php echo _('user dir') ?>
                                             </td>
                                             <td class="domain" style="padding: 0 0 0 4px;">
-                                                <b><?php echo 'cron ' . _('records') ?></b>
+                                                <b><?php echo $key ?></b>
                                             </td>
                                         </tr>
                                     </table>
@@ -271,6 +284,7 @@
                             </tr>
 
                             <?php
+                                    }
                                 }
                             ?>