1

I want to create a script at a cPanel / linux server. I want it to check on all possible errors.

    #/bin/bash
    cpanel_username=$1
domain=$2
if [ -z "$cpanel_username" ]
 then
 echo "no username given"
elif [ -z "$domain" ]
 then
 echo "no domain given"
else

/scripts/pkgacct $cpanel_username /backup/
mv /backup/cpmove-$cpanel_username.tar.gz /backup/$cpanel_username.tar.gz
FILE="/backup/$cpanel_username.tar.gz"
FTPFILE="$cpanel_username.tar.gz"
 
 if [ -f "$FILE" ]
 then
        ### FTP login credentials bellow ###
        FTPU="ftpuser"
        FTPP="ftpass"
        FTPS="host"
        lftp -u $FTPU,$FTPP -e "cd /hosting_backups;put $FILE;quit" $FTPS
        ######HERE I WANT TO CHECK IF THE FILE IS UPLOADED
        rm /backup/$cpanel_username.tar.gz
 else
        echo "couldnt take backup of $domain" 
 fi
fi

Also i would like to know if i can check if there is enough space for me to take backup. I want this to be done before the backup command.

I have tried many hours , but i couldnt make it . Any help is appreciated

sLumER
  • 11
  • 4
  • For your "check if file uploaded" function, I would put the name of the backup in a variable, connect again via FTP and use file test operations using the aforementioned name variable. See: http://tldp.org/LDP/abs/html/fto.html – D. Foley Jan 26 '17 at 13:33
  • does file operations work over ftp protocol ? – sLumER Jan 27 '17 at 06:40
  • I don't see why not. Generally anything you can do in a bash shell environment, you can also script. I can FTP mount something, CD to it and the use file test operations on whatever I want, that means you should not have a problem doing that in a script. – D. Foley Jan 27 '17 at 09:08

0 Answers0