Browse Source

FTP backup target implementation - basic auth / user-password + many fixes

master
Guillaume REMBERT 6 years ago
parent
commit
5ea229a441
  1. 35
      cfg/sw/eurybox.conf
  2. 35
      sw/src/eurybox.functions.backup
  3. 20
      sw/src/eurybox.functions.check
  4. 84
      sw/src/eurybox.functions.create
  5. 14
      sw/src/eurybox.functions.tools

35
cfg/sw/eurybox.conf

@ -9,13 +9,13 @@ EURYBOX_CORPORATE="My Corporate" @@ -9,13 +9,13 @@ EURYBOX_CORPORATE="My Corporate"
#Details level on script execution
#Can be: debug, verbose, info, warning or error
EURYBOX_LOG_LEVEL="verbose"
EURYBOX_LOG_LEVEL="debug"
#Parallelism depth / depends on host CPU
EURYBOX_PARALLELISM_LEVEL="8"
#Max retry on failure before stopping execution
EURYBOX_MAX_RETRY_ON_FAILURE="5"
#Network calls timeout (in seconds)
EURYBOX_NETWORK_TIMEOUT="1"
EURYBOX_NETWORK_TIMEOUT="2"
#Version
EURYBOX_VERSION="1.0"
@ -49,12 +49,12 @@ EURYBOX_SERVICES=( @@ -49,12 +49,12 @@ EURYBOX_SERVICES=(
[1,OS]="openbsd5"
## [1,SERV]="GATEWAY"
## [1,TYPE]="pf"
[2,NAME]="srv001m"
[2,HOST]="srv001m.$EURYBOX_DOMAIN"
[2,PORT]="22"
[2,USER]="root"
[2,DISK]="/vm_storage/images/srv001m_hdd1.qcow2 /vm_storage/images/srv001m_hdd2.qcow2 /home/vm_store/service001b.qcow2"
[2,OS]="centos7"
# [2,NAME]="srv001m"
# [2,HOST]="srv001m.$EURYBOX_DOMAIN"
# [2,PORT]="22"
# [2,USER]="root"
# [2,DISK]="/vm_storage/images/srv001m_hdd1.qcow2 /vm_storage/images/srv001m_hdd2.qcow2 /home/vm_store/service001b.qcow2"
# [2,OS]="centos7"
## [2,SERV]="DHCP"
## [2,TYPE]="dhcpd"
)
@ -103,38 +103,39 @@ EURYBOX_BACKUP_ARCHIVE=( @@ -103,38 +103,39 @@ EURYBOX_BACKUP_ARCHIVE=(
[OWNER]="root:root"
[MASK]="400"
[LABEL]="backup_u:object_r:backup_t:s0"
[FORMAT]="tar.bz2"
[FORMAT]="tar"
[HASH]="sha512"
[ECC]="par2"
[ECC_LEVEL]="10"
[ENCRYPT]="true"
[ENC_ALGO]="aes-256-ctr"
[PASSWORD]="PutYourStrongPasswordHere"
[PASSWORD]="MyStrongEncryptionPassword"
)
#Backup destination
#PROTOCOL= SSH/NFS/FTP/PART/LOCAL/ISCSI
#Protocol options details
#-SSH: ssh client/server configuration done at system level + local mount point provided by sshfs. Password authentication capability has been enforced as disabled by command options
#-SSH: ssh client/server configuration done at system level (.ssh local files) + local mount point provided by sshfs. Password authentication capability has been enforced as disabled by command options
#-NFS: nfs client/server configuration + local mount point provided by kernel.
#-ISCSI: TODO - iSCSI target/initiator configuration + local mount point provided by TBD
#-FTP: TODO - ftp client/server authentication (password or certificates) + mount provided by curlftpfs.
#-FTP: ftp client/server authentication (user/password TODO? certs/.netrc/other) + mount provided by curlftpfs.
#-PART: local unmounted partition or raw device (as USB device, additional disks, ...) + local mount point provided by kernel. TODO: LUKS encrypted partition provided by kernel and cryptsetup tool
#-LOCAL: local directory
EURYBOX_BACKUP_DESTINATION=(
[PROTOCOL]="NFS"
[PROTOCOL]="FTP"
[MOUNT]="/mnt/local_backup_folder"
#FOR SSH AND FTP
[USER]="root"
#FOR SSH, FTP AND NFS
# [PORT]="22"
[PORT]="2049"
[USER]="test"
#FOR SSH(22), FTP(21) AND NFS(2049)
[PORT]="21"
[HOST]="10.10.10.10"
[PATH]="/mnt/backup/eurybox_archives"
#FOR NFS ONLY
[TYPE]="nfs4"
#FOR PART ONLY
[PART]="/dev/sde"
#FOR FTP ONLY
[PASSWORD]="MyStrongFTPPassword"
)
##########################

35
sw/src/eurybox.functions.backup

@ -22,6 +22,7 @@ eurybox_backup_mount_target () @@ -22,6 +22,7 @@ eurybox_backup_mount_target ()
local NMAP_OUT
local NFS_OUT
local SSH_OUT
local FTP_OUT
local PART_OUT
local BKP_PROTOCOL=${EURYBOX_BACKUP_DESTINATION[PROTOCOL]}
local BKP_DEST=${EURYBOX_BACKUP_DESTINATION[PATH]}
@ -31,6 +32,7 @@ eurybox_backup_mount_target () @@ -31,6 +32,7 @@ eurybox_backup_mount_target ()
local BKP_HOST=${EURYBOX_BACKUP_DESTINATION[HOST]}
local BKP_TYPE=${EURYBOX_BACKUP_DESTINATION[TYPE]}
local BKP_PART=${EURYBOX_BACKUP_DESTINATION[PART]}
local BKP_PASSWORD=${EURYBOX_BACKUP_DESTINATION[PASSWORD]}
if [[ $EURYBOX_LOG_LEVEL = "debug" || $EURYBOX_LOG_LEVEL = "verbose" ]]
then
@ -47,7 +49,7 @@ eurybox_backup_mount_target () @@ -47,7 +49,7 @@ eurybox_backup_mount_target ()
then
eurybox_display_message error BACKUP "Target local mount point directory $BKP_MOUNT doesn't exists and folder creation failed - error $STATUS:\n$MKDIR_OUT"
else
local CHMOD_OUT=`sudo chmod 700 $BKP_MOUNT 2>&1`
local CHMOD_OUT=`sudo chmod 777 $BKP_MOUNT 2>&1`
STATUS=$?
if [[ !($STATUS -eq 0) ]]
then
@ -74,7 +76,7 @@ eurybox_backup_mount_target () @@ -74,7 +76,7 @@ eurybox_backup_mount_target ()
STATUS=$?
if [[ !($STATUS -eq 0) ]]
then
eurybox_display_message warning BACKUP "Backup target $BKP_PROTOCOL server unreacheable on host $BKP_HOST / port $BKP_PORT - trying to contact again in 5 seconds - error $STATUS:\n$NMAP_OUT\n$NB_TRY_LEFT left"
eurybox_display_message warning BACKUP "Backup target $BKP_PROTOCOL server unreacheable on host $BKP_HOST / port $BKP_PORT - trying to contact again in 5 seconds - error $STATUS\n$NB_TRY_LEFT left"
NB_TRY_LEFT=$(( $NB_TRY_LEFT - 1 ))
sleep 5
else
@ -89,6 +91,7 @@ eurybox_backup_mount_target () @@ -89,6 +91,7 @@ eurybox_backup_mount_target ()
NB_TRY_LEFT=$(( $NB_TRY_LEFT - 1 ))
sleep 5
else
eurybox_display_message debug BACKUP "Backup target $BKP_PROTOCOL server reached on host $BKP_HOST / port $BKP_PORT\n$NFS_OUT"
MOUNT_OUT=`sudo mount $MOUNT_OPTIONS $EURYBOX_MNT_NFS_OPTIONS -o proto=tcp,port=${BKP_PORT} -t $BKP_TYPE ${BKP_HOST}:${BKP_DEST} ${BKP_MOUNT} 2>&1`
STATUS=$?
if [[ !($STATUS -eq 0) ]]
@ -105,11 +108,11 @@ eurybox_backup_mount_target () @@ -105,11 +108,11 @@ eurybox_backup_mount_target ()
STATUS=$?
if [[ !($STATUS -eq 0) ]]
then
eurybox_display_message warning BACKUP "Backup target $BKP_PROTOCOL server unreacheable on host $BKP_HOST / port $BKP_PORT - trying to contact again in 5 seconds - error $STATUS:\n$SSH_OUT\n$NB_TRY_LEFT left"
eurybox_display_message warning BACKUP "Backup SSH server unreacheable on host $BKP_HOST / port $BKP_PORT - trying to contact again in 5 seconds - error $STATUS:\n$SSH_OUT\n$NB_TRY_LEFT left"
NB_TRY_LEFT=$(( $NB_TRY_LEFT - 1 ))
sleep 5
else
eurybox_display_message debug BACKUP "Backup target $BKP_PROTOCOL server reached on host $BKP_HOST / port $BKP_PORT"
eurybox_display_message debug BACKUP "Backup target $BKP_PROTOCOL server reached on host $BKP_HOST / port $BKP_PORT\n$SSH_OUT"
MOUNT_OUT=`sshfs $EURYBOX_MNT_SSHFS_OPTIONS -p $BKP_PORT ${BKP_USER}@${BKP_HOST}:${BKP_DEST} ${BKP_MOUNT} 2>&1`
STATUS=$?
if [[ !($STATUS -eq 0) ]]
@ -121,7 +124,25 @@ eurybox_backup_mount_target () @@ -121,7 +124,25 @@ eurybox_backup_mount_target ()
fi
;;
FTP )
eurybox_display_message error BACKUP "Backup destination FTP not implemented yet"
#Check access
FTP_OUT=`sudo lftp -p ${BKP_PORT} ftp://${BKP_USER}:${BKP_PASSWORD}@${BKP_HOST} -e "quit" 2>&1`
STATUS=$?
if [[ !($STATUS -eq 0) ]]
then
eurybox_display_message warning BACKUP "Backup target $BKP_PROTOCOL server unreacheable on host $BKP_HOST / port $BKP_PORT - trying to contact again in 5 seconds - error $STATUS:\n$FTP_OUT\n$NB_TRY_LEFT left"
NB_TRY_LEFT=$(( $NB_TRY_LEFT - 1 ))
sleep 5
else
eurybox_display_message debug BACKUP "Backup target $BKP_PROTOCOL server reached on host $BKP_HOST / port $BKP_PORT\n$FTP_OUT"
MOUNT_OUT=`sudo curlftpfs $EURYBOX_MNT_FTPFS_OPTIONS ftp://${BKP_USER}:${BKP_PASSWORD}@${BKP_HOST}:${BKP_PORT}${BKP_DEST} ${BKP_MOUNT} 2>&1`
STATUS=$?
if [[ !($STATUS -eq 0) ]]
then
NB_TRY_LEFT=$(( $NB_TRY_LEFT - 1 ))
eurybox_display_message warning BACKUP "Backup target FTPFS mount failed and target folder is empty - trying to mount again in 5 seconds - error $STATUS:\n$MOUNT_OUT\n$NB_TRY_LEFT left"
sleep 5
fi
fi
;;
esac
fi
@ -156,7 +177,7 @@ eurybox_backup_mount_target () @@ -156,7 +177,7 @@ eurybox_backup_mount_target ()
if [[ $NB_TRY_LEFT -eq 0 ]]
then
eurybox_display_message error BACKUP "Backup target mount failed:\n$MOUNT_OUT $NFS_OUT $NMAP_OUT $SSH_OUT $PART_OUT"
eurybox_display_message error BACKUP "Backup target mount failed:\n$MOUNT_OUT $NFS_OUT $NMAP_OUT $SSH_OUT $FTP_OUT $PART_OUT"
else
eurybox_display_message message BACKUP "Backup target mount success"
eurybox_display_message debug BACKUP "Mount command output:\n$MOUNT_OUT"
@ -232,7 +253,7 @@ eurybox_backup_umount_target () @@ -232,7 +253,7 @@ eurybox_backup_umount_target ()
#Nothing to do
STATUS=0
;;
NFS|SSH|PART )
NFS|SSH|FTP|PART )
UMOUNT_OUT=`sudo umount $UMOUNT_OPTIONS ${EURYBOX_BACKUP_DESTINATION[MOUNT]} 2>&1`
STATUS=$?
if [[ !($STATUS -eq 0) ]]

20
sw/src/eurybox.functions.check

@ -126,7 +126,8 @@ eurybox_check_configuration () @@ -126,7 +126,8 @@ eurybox_check_configuration ()
EURYBOX_NMAP_OPTIONS="--host-timeout $EURYBOX_NETWORK_TIMEOUT --max-retries $EURYBOX_MAX_RETRY_ON_FAILURE"
EURYBOX_LS_OPTIONS="-x"
EURYBOX_MNT_NFS_OPTIONS="-o hard,retry=$EURYBOX_MAX_RETRY_ON_FAILURE,rsize=8192,wsize=8192,timeo=${EURYBOX_NETWORK_TIMEOUT}0"
EURYBOX_MNT_SSHFS_OPTIONS="-o allow_root,large_read ${EURYBOX_SSH_OPTIONS}"
EURYBOX_MNT_SSHFS_OPTIONS="-o allow_root ${EURYBOX_SSH_OPTIONS}"
EURYBOX_MNT_FTPFS_OPTIONS="-o allow_root,connect_timeout=${EURYBOX_NETWORK_TIMEOUT}"
case $EURYBOX_LOG_LEVEL in
debug )
set -xv
@ -135,7 +136,8 @@ eurybox_check_configuration () @@ -135,7 +136,8 @@ eurybox_check_configuration ()
EURYBOX_LS_OPTIONS+=" -a"
EURYBOX_MNT_NFS_OPTIONS+=" -v"
EURYBOX_MNT_SSHFS_OPTIONS+=" -oLogLevel=debug"
EURYBOX_VIRSH_OPTIONS+=" -q -d 0"
EURYBOX_MNT_FTPFS_OPTIONS+=" -v"
EURYBOX_VIRSH_OPTIONS+=" -q -d 2"
;;
verbose )
set -v
@ -144,14 +146,15 @@ eurybox_check_configuration () @@ -144,14 +146,15 @@ eurybox_check_configuration ()
EURYBOX_LS_OPTIONS+=" -l"
EURYBOX_MNT_NFS_OPTIONS+=" -v"
EURYBOX_MNT_SSHFS_OPTIONS+=" -oLogLevel=verbose"
EURYBOX_VIRSH_OPTIONS+=" -q -d 2"
EURYBOX_MNT_FTPFS_OPTIONS+=" -v"
EURYBOX_VIRSH_OPTIONS+=" -q -d 4"
;;
info )
EURYBOX_SSH_OPTIONS+=" -oLogLevel=info"
EURYBOX_NMAP_OPTIONS+=" -d0 -v"
EURYBOX_LS_OPTIONS+=" -l"
EURYBOX_MNT_SSHFS_OPTIONS+=" -oLogLevel=info"
EURYBOX_VIRSH_OPTIONS+=" -q -d 4"
EURYBOX_VIRSH_OPTIONS+=" -q -d 6"
;;
warning )
EURYBOX_SSH_OPTIONS+=" -oLogLevel=info"
@ -167,11 +170,12 @@ eurybox_check_configuration () @@ -167,11 +170,12 @@ eurybox_check_configuration ()
;;
esac
eurybox_display_message debug CHECK "ssh options: $EURYBOX_SSH_OPTIONS"
eurybox_display_message debug CHECK "sshfs options: $EURYBOX_MNT_SSHFS_OPTIONS"
eurybox_display_message debug CHECK "nmap options: $EURYBOX_NMAP_OPTIONS"
eurybox_display_message debug CHECK "ls options: $EURYBOX_LS_OPTIONS"
eurybox_display_message debug CHECK "nfs mount options: $EURYBOX_MNT_NFS_OPTIONS"
eurybox_display_message debug CHECK "virsh options: $EURYBOX_VIRSH_OPTIONS"
eurybox_display_message debug CHECK "nfs mount options: $EURYBOX_MNT_NFS_OPTIONS"
eurybox_display_message debug CHECK "sshfs mount options: $EURYBOX_MNT_SSHFS_OPTIONS"
eurybox_display_message debug CHECK "ftpfs mount options: $EURYBOX_MNT_FTPFS_OPTIONS"
}
#Desc: verify the kernel is Linux
@ -257,7 +261,7 @@ eurybox_check_environment () @@ -257,7 +261,7 @@ eurybox_check_environment ()
local BKP_SPACE_LEFT
local BKP_ACCESS_OK
#Check external sotfware used
eurybox_check_command grep sudo ssh openssl tar par2 virsh sha512sum sha256sum awk pigz df tail virt-sysprep tput nmap rpcinfo pbzip2 sshfs curlftpfs cryptsetup
eurybox_check_command grep sudo ssh openssl tar par2 virsh sha512sum sha256sum awk pigz df tail virt-sysprep tput nmap rpcinfo pbzip2 sshfs curlftpfs lftp cryptsetup
#Check kernel capabilities
eurybox_check_kernel
#Check distribution is coherent with configuration
@ -308,7 +312,7 @@ eurybox_check_environment () @@ -308,7 +312,7 @@ eurybox_check_environment ()
fi
fi
#Check bkp destination access (READ/WRITE)
BKP_ACCESS_OK=`sudo touch ${EURYBOX_BACKUP_DESTINATION[MOUNT]}/test && sudo rm ${EURYBOX_BACKUP_DESTINATION[MOUNT]}/test`
BKP_ACCESS_OK=`sudo sh -c "touch ${EURYBOX_BACKUP_DESTINATION[MOUNT]}/test && rm -Rf ${EURYBOX_BACKUP_DESTINATION[MOUNT]}/test"`
STATUS=$?
if [[ !($STATUS -eq 0) ]]
then

84
sw/src/eurybox.functions.create

@ -7,6 +7,7 @@ eurybox_create_archive_desc () @@ -7,6 +7,7 @@ eurybox_create_archive_desc ()
local DESC_OUT
local SYNC_OUT
local STATUS
local DESCRIPTION
#TODO: IMPLEMENT PARALLEL EXTRACTION FOR GZ AND BZ2
case ${EURYBOX_BACKUP_ARCHIVE[FORMAT]} in
"tar" ) TAR_OPTIONS="-Stv" ;;
@ -15,52 +16,65 @@ eurybox_create_archive_desc () @@ -15,52 +16,65 @@ eurybox_create_archive_desc ()
esac
STATUS=1234
DESTINATION=${EURYBOX_BACKUP_DESTINATION[MOUNT]}/${EURYBOX_BACKUP_ARCHIVE[NAME]}.desc
DESC_OUT=`sudo sh -c "echo ARCHIVE_CONTENT:$EURYBOX_CORPORATE >> $DESTINATION" 2>&1`
DESC_OUT=`sudo sh -c "echo ARCHIVE_FILE:${EURYBOX_BACKUP_ARCHIVE[NAME]} >> $DESTINATION" 2>&1`
DESC_OUT=`sudo sh -c "echo ARCHIVE_FORMAT:${EURYBOX_BACKUP_ARCHIVE[FORMAT]} >> $DESTINATION" 2>&1`
DESC_OUT=`sudo sh -c "echo ARCHIVE_TARGETS:${EURYBOX_BACKUP_TARGETS[*]} >> $DESTINATION" 2>&1`
DESC_OUT=`sudo sh -c "echo ARCHIVE_TYPE:$EURYBOX_BACKUP_TYPE >> $DESTINATION" 2>&1`
DESC_OUT=`sudo sh -c "echo ARCHIVE_VERSION:$EURYBOX_VERSION >> $DESTINATION" 2>&1`
DESC_OUT=`sudo sh -c "echo ECC_FILE:${EURYBOX_BACKUP_ARCHIVE[NAME]}.${EURYBOX_BACKUP_ARCHIVE[ECC]} >> $DESTINATION" 2>&1`
DESC_OUT=`sudo sh -c "echo ECC_FORMAT:${EURYBOX_BACKUP_ARCHIVE[ECC]} >> $DESTINATION" 2>&1`
DESC_OUT=`sudo sh -c "echo ECC_LEVEL:${EURYBOX_BACKUP_ARCHIVE[ECC_LEVEL]\%} >> $DESTINATION" 2>&1`
DESC_OUT=`sudo sh -c "echo HASH_FILE:${EURYBOX_BACKUP_ARCHIVE[NAME]}.${EURYBOX_BACKUP_ARCHIVE[HASH]} >> $DESTINATION" 2>&1`
DESC_OUT=`sudo sh -c "echo HASH_FORMAT:${EURYBOX_BACKUP_ARCHIVE[HASH]} >> $DESTINATION" 2>&1`
DESC_OUT=`sudo sh -c "echo ENCRYPTED_ARCHIVE:${EURYBOX_BACKUP_ARCHIVE[ENCRYPT]} >> $DESTINATION" 2>&1`
DESCRIPTION="ARCHIVE_CONTENT:${EURYBOX_CORPORATE}\nARCHIVE_FILE:${EURYBOX_BACKUP_ARCHIVE[NAME]}\nARCHIVE_FORMAT:${EURYBOX_BACKUP_ARCHIVE[FORMAT]}\nARCHIVE_TARGETS:${EURYBOX_BACKUP_TARGETS[*]}\nARCHIVE_TYPE:${EURYBOX_BACKUP_TYPE}\nARCHIVE_VERSION:${EURYBOX_VERSION}\nECC_FILE:${EURYBOX_BACKUP_ARCHIVE[NAME]}.${EURYBOX_BACKUP_ARCHIVE[ECC]}\nECC_FORMAT:${EURYBOX_BACKUP_ARCHIVE[ECC]}\nECC_LEVEL:${EURYBOX_BACKUP_ARCHIVE[ECC_LEVEL]\%}\nHASH_FILE:${EURYBOX_BACKUP_ARCHIVE[NAME]}.${EURYBOX_BACKUP_ARCHIVE[HASH]}\nENCRYPTED_ARCHIVE:${EURYBOX_BACKUP_ARCHIVE[ENCRYPT]}\n"
# DESC_OUT=`sudo sh -c "echo ARCHIVE_CONTENT:$EURYBOX_CORPORATE >> $DESTINATION" 2>&1`
# DESC_OUT=`sudo sh -c "echo ARCHIVE_FILE:${EURYBOX_BACKUP_ARCHIVE[NAME]} >> $DESTINATION" 2>&1`
# DESC_OUT=`sudo sh -c "echo ARCHIVE_FORMAT:${EURYBOX_BACKUP_ARCHIVE[FORMAT]} >> $DESTINATION" 2>&1`
# DESC_OUT=`sudo sh -c "echo ARCHIVE_TARGETS:${EURYBOX_BACKUP_TARGETS[*]} >> $DESTINATION" 2>&1`
# DESC_OUT=`sudo sh -c "echo ARCHIVE_TYPE:$EURYBOX_BACKUP_TYPE >> $DESTINATION" 2>&1`
# DESC_OUT=`sudo sh -c "echo ARCHIVE_VERSION:$EURYBOX_VERSION >> $DESTINATION" 2>&1`
# DESC_OUT=`sudo sh -c "echo ECC_FILE:${EURYBOX_BACKUP_ARCHIVE[NAME]}.${EURYBOX_BACKUP_ARCHIVE[ECC]} >> $DESTINATION" 2>&1`
# DESC_OUT=`sudo sh -c "echo ECC_FORMAT:${EURYBOX_BACKUP_ARCHIVE[ECC]} >> $DESTINATION" 2>&1`
# DESC_OUT=`sudo sh -c "echo ECC_LEVEL:${EURYBOX_BACKUP_ARCHIVE[ECC_LEVEL]\%} >> $DESTINATION" 2>&1`
# DESC_OUT=`sudo sh -c "echo HASH_FILE:${EURYBOX_BACKUP_ARCHIVE[NAME]}.${EURYBOX_BACKUP_ARCHIVE[HASH]} >> $DESTINATION" 2>&1`
# DESC_OUT=`sudo sh -c "echo HASH_FORMAT:${EURYBOX_BACKUP_ARCHIVE[HASH]} >> $DESTINATION" 2>&1`
# DESC_OUT=`sudo sh -c "echo ENCRYPTED_ARCHIVE:${EURYBOX_BACKUP_ARCHIVE[ENCRYPT]} >> $DESTINATION" 2>&1`
if [[ ${EURYBOX_BACKUP_ARCHIVE[ENCRYPT]} = "true" ]]
then
DESC_OUT=`sudo sh -c "echo ENCRYPTION_ALGORITHM:${EURYBOX_BACKUP_ARCHIVE[ENC_ALGO]} >> $DESTINATION" 2>&1`
DESC_OUT=`sudo sh -c "echo ARCHIVE_CONTENT: >> $DESTINATION" 2>&1`
DESCRIPTION+="ENCRYPTION_ALGORITHM:${EURYBOX_BACKUP_ARCHIVE[ENC_ALGO]}\nARCHIVE_CONTENT:\n"
#FIXME: function to read archive with variable archive format required here
DESC_OUT=$((
(
sudo sh -c "openssl enc -${EURYBOX_BACKUP_ARCHIVE[ENC_ALGO]} -d -in ${EURYBOX_BACKUP_DESTINATION[MOUNT]}/${EURYBOX_BACKUP_ARCHIVE[NAME]}.${EURYBOX_BACKUP_ARCHIVE[FORMAT]} -k ${EURYBOX_BACKUP_ARCHIVE[PASSWORD]} | tar ${TAR_OPTIONS} >> $DESTINATION"
DESCRIPTION+=`sudo sh -c "openssl enc -${EURYBOX_BACKUP_ARCHIVE[ENC_ALGO]} -d -in ${EURYBOX_BACKUP_DESTINATION[MOUNT]}/${EURYBOX_BACKUP_ARCHIVE[NAME]}.${EURYBOX_BACKUP_ARCHIVE[FORMAT]} -k ${EURYBOX_BACKUP_ARCHIVE[PASSWORD]} | tar ${TAR_OPTIONS}"`
# DESC_OUT=`sudo sh -c "echo ENCRYPTION_ALGORITHM:${EURYBOX_BACKUP_ARCHIVE[ENC_ALGO]} >> $DESTINATION" 2>&1`
# DESC_OUT=`sudo sh -c "echo ARCHIVE_CONTENT: >> $DESTINATION" 2>&1`
# DESC_OUT=$((
# (
# sudo sh -c "openssl enc -${EURYBOX_BACKUP_ARCHIVE[ENC_ALGO]} -d -in ${EURYBOX_BACKUP_DESTINATION[MOUNT]}/${EURYBOX_BACKUP_ARCHIVE[NAME]}.${EURYBOX_BACKUP_ARCHIVE[FORMAT]} -k ${EURYBOX_BACKUP_ARCHIVE[PASSWORD]} | tar ${TAR_OPTIONS} >> $DESTINATION"
# STATUS=$(( ${PIPESTATUS[0]} + ${PIPESTATUS[1]} ))
)) 2>&1)
# )) 2>&1)
STATUS=$?
else
DESC_OUT=`sudo sh -c "sudo echo ARCHIVE_CONTENT: >> $DESTINATION" 2>&1`
DESCRIPTION+="ARCHIVE_CONTENT:\n"
#FIXME: function to read archive with variable archive format required here
DESC_OUT=$((
(
sudo sh -c "tar ${TAR_OPTIONS}f ${EURYBOX_BACKUP_DESTINATION[MOUNT]}/${EURYBOX_BACKUP_ARCHIVE[NAME]}.${EURYBOX_BACKUP_ARCHIVE[FORMAT]} >> $DESTINATION"
)) 2>&1)
DESCRIPTION+=`sudo sh -c "tar ${TAR_OPTIONS}f ${EURYBOX_BACKUP_DESTINATION[MOUNT]}/${EURYBOX_BACKUP_ARCHIVE[NAME]}.${EURYBOX_BACKUP_ARCHIVE[FORMAT]}"`
# DESC_OUT=`sudo sh -c "sudo echo ARCHIVE_CONTENT: >> $DESTINATION" 2>&1`
# DESC_OUT=$((
# (
# sudo sh -c "tar ${TAR_OPTIONS}f ${EURYBOX_BACKUP_DESTINATION[MOUNT]}/${EURYBOX_BACKUP_ARCHIVE[NAME]}.${EURYBOX_BACKUP_ARCHIVE[FORMAT]} >> $DESTINATION"
# )) 2>&1)
STATUS=$?
fi
if [[ !($STATUS -eq 0) ]]
then
eurybox_display_message warning CREATE "Archive description creation failed - error $STATUS:\n$DESC_OUT"
eurybox_display_message warning CREATE "Archive description creation failed - error $STATUS:\n$DESCRIPTION"
else
eurybox_display_message message CREATE "Archive description creation - OK"
eurybox_display_message debug CREATE "Description command output:\n$DESC_OUT"
SYNC_OUT=`sudo sync 2>&1`
DESC_OUT=`sudo sh -c "printf %b \"$DESCRIPTION\" > $DESTINATION" 2>&1`
STATUS=$?
if [[ !($STATUS -eq 0) ]]
then
eurybox_display_message warning CREATE "Archive description FS sync failed - error $STATUS:\n$SYNC_OUT"
eurybox_display_message warning CREATE "Archive description write failed - error $STATUS:\n$DESC_OUT"
else
eurybox_display_message message CREATE "Archive description FS sync - OK"
eurybox_display_message debug CREATE "Sync command output:\n$SYNC_OUT"
eurybox_display_message message CREATE "Archive description creation - OK"
eurybox_display_message debug CREATE "Description:\n$DESCRIPTION"
eurybox_display_message debug CREATE "Description command output:\n$DESC_OUT"
SYNC_OUT=`sudo sync 2>&1`
STATUS=$?
if [[ !($STATUS -eq 0) ]]
then
eurybox_display_message warning CREATE "Archive description FS sync failed - error $STATUS:\n$SYNC_OUT"
else
eurybox_display_message message CREATE "Archive description FS sync - OK"
eurybox_display_message debug CREATE "Sync command output:\n$SYNC_OUT"
fi
fi
fi
}
@ -87,12 +101,12 @@ eurybox_create_archive_tar () @@ -87,12 +101,12 @@ eurybox_create_archive_tar ()
then
TAR_OUT=$((
(
sudo tar ${TAR_OPTIONS} ${EURYBOX_BACKUP_TARGETS[*]} | sudo openssl enc -salt -e -${EURYBOX_BACKUP_ARCHIVE[ENC_ALGO]} -k ${EURYBOX_BACKUP_ARCHIVE[PASSWORD]} -out ${EURYBOX_BACKUP_DESTINATION[MOUNT]}/${EURYBOX_BACKUP_ARCHIVE[NAME]}.${EURYBOX_BACKUP_ARCHIVE[FORMAT]}
sudo sh -c "tar ${TAR_OPTIONS} ${EURYBOX_BACKUP_TARGETS[*]} | openssl enc -salt -e -${EURYBOX_BACKUP_ARCHIVE[ENC_ALGO]} -k ${EURYBOX_BACKUP_ARCHIVE[PASSWORD]} -out ${EURYBOX_BACKUP_DESTINATION[MOUNT]}/${EURYBOX_BACKUP_ARCHIVE[NAME]}.${EURYBOX_BACKUP_ARCHIVE[FORMAT]}"
# STATUS=$(( ${PIPESTATUS[0]} + ${PIPESTATUS[1]} ))
)) 2>&1)
STATUS=$?
else
TAR_OUT=`sudo tar ${TAR_OPTIONS} -f ${EURYBOX_BACKUP_DESTINATION[MOUNT]}/${EURYBOX_BACKUP_ARCHIVE[NAME]}.${EURYBOX_BACKUP_ARCHIVE[FORMAT]} ${EURYBOX_BACKUP_TARGETS[*]} 2>&1`
TAR_OUT=`sudo sh -c "tar ${TAR_OPTIONS} -f ${EURYBOX_BACKUP_DESTINATION[MOUNT]}/${EURYBOX_BACKUP_ARCHIVE[NAME]}.${EURYBOX_BACKUP_ARCHIVE[FORMAT]} ${EURYBOX_BACKUP_TARGETS[*]}" 2>&1`
STATUS=$?
fi
if [[ !($STATUS -eq 0) ]]
@ -127,7 +141,7 @@ eurybox_create_archive_par () @@ -127,7 +141,7 @@ eurybox_create_archive_par ()
esac
case "${EURYBOX_BACKUP_ARCHIVE[ECC]}" in
"par2" )
PAR_OUT=`sudo par2 c $PAR_OPTIONS -r${EURYBOX_BACKUP_ARCHIVE[ECC_LEVEL]} -t+ ${EURYBOX_BACKUP_DESTINATION[MOUNT]}/${EURYBOX_BACKUP_ARCHIVE[NAME]}.${EURYBOX_BACKUP_ARCHIVE[ECC]} ${EURYBOX_BACKUP_DESTINATION[MOUNT]}/${EURYBOX_BACKUP_ARCHIVE[NAME]}.${EURYBOX_BACKUP_ARCHIVE[FORMAT]} 2>&1`
PAR_OUT=`sudo sh -c "par2 c $PAR_OPTIONS -r${EURYBOX_BACKUP_ARCHIVE[ECC_LEVEL]} -t+ ${EURYBOX_BACKUP_DESTINATION[MOUNT]}/${EURYBOX_BACKUP_ARCHIVE[NAME]}.${EURYBOX_BACKUP_ARCHIVE[ECC]} ${EURYBOX_BACKUP_DESTINATION[MOUNT]}/${EURYBOX_BACKUP_ARCHIVE[NAME]}.${EURYBOX_BACKUP_ARCHIVE[FORMAT]}" 2>&1`
STATUS=$?
;;
* )
@ -166,11 +180,11 @@ eurybox_create_archive_sha () @@ -166,11 +180,11 @@ eurybox_create_archive_sha ()
esac
case "${EURYBOX_BACKUP_ARCHIVE[HASH]}" in
"sha256" )
SHA_OUT=`sudo sh -c "sha256sum $SHA_OPTIONS ${EURYBOX_BACKUP_DESTINATION[MOUNT]}/${EURYBOX_BACKUP_ARCHIVE[NAME]}* > ${EURYBOX_BACKUP_DESTINATION[MOUNT]}/${EURYBOX_BACKUP_ARCHIVE[NAME]}.${EURYBOX_BACKUP_ARCHIVE[HASH]}" 2<&1`
SHA_OUT=`sudo sh -c "sha256sum $SHA_OPTIONS ${EURYBOX_BACKUP_DESTINATION[MOUNT]}/${EURYBOX_BACKUP_ARCHIVE[NAME]}* > ${EURYBOX_BACKUP_DESTINATION[MOUNT]}/${EURYBOX_BACKUP_ARCHIVE[NAME]}.${EURYBOX_BACKUP_ARCHIVE[HASH]}" 2>&1`
STATUS=$?
;;
"sha512" )
SHA_OUT=`sudo sh -c "sha512sum $SHA_OPTIONS ${EURYBOX_BACKUP_DESTINATION[MOUNT]}/${EURYBOX_BACKUP_ARCHIVE[NAME]}* > ${EURYBOX_BACKUP_DESTINATION[MOUNT]}/${EURYBOX_BACKUP_ARCHIVE[NAME]}.${EURYBOX_BACKUP_ARCHIVE[HASH]}" 2<&1`
SHA_OUT=`sudo sh -c "sha512sum $SHA_OPTIONS ${EURYBOX_BACKUP_DESTINATION[MOUNT]}/${EURYBOX_BACKUP_ARCHIVE[NAME]}* > ${EURYBOX_BACKUP_DESTINATION[MOUNT]}/${EURYBOX_BACKUP_ARCHIVE[NAME]}.${EURYBOX_BACKUP_ARCHIVE[HASH]}" 2>&1`
STATUS=$?
;;
* )

14
sw/src/eurybox.functions.tools

@ -37,13 +37,13 @@ eurybox_change_file_permissions () @@ -37,13 +37,13 @@ eurybox_change_file_permissions ()
eurybox_display_message message TOOLS "MAC label changed with success"
eurybox_display_message debug TOOLS "MAC label output command:\n$PERMISSIONS_OUT"
fi
PERMISSIONS_OUT=`sudo ls -aZ $FILE 2>&1`
PERMISSIONS_OUT=`sudo sh -c "ls -aZ $FILE" 2>&1`
STATUS=$?
if [[ !($STATUS -eq 0) ]]
then
eurybox_display_message warning TOOLS "Permissions listing failed - error $STATUS:\n$PERMISSIONS_OUT"
else
eurybox_display_message message TOOLS "Final files permissions:\n$PERMISSIONS_OUT"
eurybox_display_message message TOOLS "Final permissions:\n$PERMISSIONS_OUT"
fi
}
@ -61,7 +61,7 @@ eurybox_display_message () @@ -61,7 +61,7 @@ eurybox_display_message ()
then
tput setb 0
tput setaf 6
printf "$NOW [EURYBOX][DEBUG][$CATEGORY] %b\n" "$MESSAGE"
printf "$NOW [EURYBOX][$CATEGORY][DEBUG] %b\n" "$MESSAGE"
fi
;;
message )
@ -69,7 +69,7 @@ eurybox_display_message () @@ -69,7 +69,7 @@ eurybox_display_message ()
then
tput setb 0
tput setaf 2
printf "$NOW [EURYBOX][INFO][$CATEGORY] %b\n" "$MESSAGE"
printf "$NOW [EURYBOX][$CATEGORY][INFO] %b\n" "$MESSAGE"
fi
;;
warning )
@ -77,7 +77,7 @@ eurybox_display_message () @@ -77,7 +77,7 @@ eurybox_display_message ()
then
tput setb 0
tput setaf 1
printf "$NOW [EURYBOX][WARNING][$CATEGORY] %b\n" "$MESSAGE"
printf "$NOW [EURYBOX][$CATEGORY][WARNING] %b\n" "$MESSAGE"
fi
;;
error )
@ -85,7 +85,7 @@ eurybox_display_message () @@ -85,7 +85,7 @@ eurybox_display_message ()
then
tput setb 0
tput setaf 1
printf "$NOW [EURYBOX][ERROR][$CATEGORY] %b\n" "$MESSAGE"
printf "$NOW [EURYBOX][$CATEGORY][ERROR] %b\n" "$MESSAGE"
tput setb 0
tput sgr0
printf "Stopping script execution\n"
@ -94,7 +94,7 @@ eurybox_display_message () @@ -94,7 +94,7 @@ eurybox_display_message ()
;;
* )
tput sgr0
printf "$NOW [EURYBOX][ERROR][SYNTAX] Bad log level message. Stopping script execution\n"
printf "$NOW [EURYBOX][SYNTAX][ERROR] Bad log level message. Stopping script execution\n"
exit 1
;;
esac

Loading…
Cancel
Save