Directadmin backup Move data to google driver

itdungpt

Verified User
Joined
Aug 8, 2015
Messages
24
/usr/local/directadmin/scripts/custom/user_backup_post.sh

#!/bin/sh
#where do you want to save the Google Driver copy?
SAVE_PATH=/home/admin/admin_backups

BACKUP_PATH='echo $file | cut -d/ -f1,2,3,4,5'
REQUIRED_PATH=/home/admin/admin_backups/tmp

if [ "$BACKUP_PATH" = "$REQUIRED_PATH" ]; then
NEW_FILE=${SAVE_PATH}/'echo $file | cut -d/ -f6-'
/usr/sbin/rclone move $file "remote:$NEW_FILE"
fi
exit 0;

But can not work, how to move all then backup from directadmin ?
 
Hello,

There might be numerous reasons on why it does not work. First make sure you've got rclone installed, then check firewall to make sure all needed ports are opened. If all is done and does not fix, then configure the script to write logs into a file or send them by email to see what might be wrong.
 
rclone working good
i want use config backup directadmin auto move to google driver via rclone then conplete backup Can you share me command to auto move google driver via rclone then complete backup on directadmin ?
 
I don't use either Google drive or rclone. You say rclone works on your server good - OK.

Now you need to identify why it does not work in your script. You can try and investigate it by yourself or hire somebody for this job.

Your script is a modification of one posted here https://help.directadmin.com/item.php?id=511 So double-check it does not contain syntax or other errors. Try to run it in a console and see whether or not it alerts about errors.

Make sure then /usr/local/directadmin/scripts/custom/user_backup_post.sh is owned and group-owned by diradmin and has 700 permissions.
 
SERVER_NAME = DirectAdmin

TIMESTAMP = $ (date + "% F")
BACKUP_DIR = "/ root / backup / $ TIMESTAMP"
MYSQL_USER = "da_admin"
MYSQL = / usr / bin / mysql
MYSQL_PASSWORD = "your sql password"
MYSQLDUMP = / usr / bin / mysqldump
SECONDS = 0

mkdir -p "$ BACKUP_DIR / mysql"

echo "Starting Backup Database";
databases = `$ MYSQL --user = $ MYSQL_USER -p $ MYSQL_PASSWORD -e" SHOW DATABASES; " | grep -Ev "(Database | information_schema | performance_schema | mysql)" `

for db in $ databases; by
$ MYSQLDUMP --force --opt --user = $ MYSQL_USER -p $ MYSQL_PASSWORD $ db | gzip> "$ BACKUP_DIR / mysql / $ db.gz"
done
echo "Finished";
echo '';

echo "Starting Backup Website";
# Loop through / home directory
for D in / home / *; by
if [-d "$ {D}"]; then #If a directory
domain = $ {D ## * /} # Domain name
for C in / home / $ domain / domains / *; by
if [-d "$ {C}" -a "$ {C}"! = 'default' -a "$ {C}"! = 'suspended']; then
cuong = $ {C ## * /}
echo "-" $ cuong;
zip -r $ BACKUP_DIR / $ cuong.zip / home / $ domain / domains / $ cuong / public_html / -q -x / home / $ domain / domains / $ cuong / public_html / wp-content / cache / ** \ * #Exclude cache
fi
done
fi
done
echo "Finished";
echo '';

size = $ (du -sh $ BACKUP_DIR | awk '{print $ 1}')

echo "Starting Uploading Backup";
/ usr / sbin / rclone move $ BACKUP_DIR "remote: $ SERVER_NAME / $ TIMESTAMP" >> /var/log/rclone.log 2> & 1
# Clean up
rm -rf $ BACKUP_DIR
/ usr / sbin / rclone -q --min-age 2w delete "remote: $ SERVER_NAME" #Remove all backups older than 2 weeks
/ usr / sbin / rclone -q --min-age 2w rmdirs "remote: $ SERVER_NAME" #Remove all empty folders older than 2 week
/ usr / sbin / rclone cleanup "remote:" #Cleanup Trash
echo "Finished";
echo '';

duration = $ SECONDS
echo "Total $ size, $ (($ duration / 60)) minutes and $ (($ duration% 60)) seconds elapsed."
 
i already search this code from other website what wrong ? server name - ( that is domain name? or host name? ) this server name place wrong .. how to fix
 
I don't know whether is it a copy/paste error, but you have too many typos... white-spaces are breaking commands and paths. So you need to check your code and post here errors you have when running it, if you want a help from us.

Probably anybody who also backups files to Google Drive can give a working solution. I personally do not use Google Drive and don't have solution for it either. So it's up to you to find where it does not work. If you provide text of errors then we can guide you further.

p.s. please use formatting and put any bash code inside CODE tags.
 
/usr/local/directadmin/scripts/custom/user_backup_post.sh

#!/bin/sh
#where do you want to save the Google Driver copy?
SAVE_PATH=/home/admin/admin_backups

BACKUP_PATH='echo $file | cut -d/ -f1,2,3,4,5'
REQUIRED_PATH=/home/admin/admin_backups/tmp

if [ "$BACKUP_PATH" = "$REQUIRED_PATH" ]; then
NEW_FILE=${SAVE_PATH}/'echo $file | cut -d/ -f6-'
/usr/sbin/rclone move $file "remote:$NEW_FILE"
fi
exit 0;

But can not work, how to move all then backup from directadmin ?

The move command syntax is incorrect. You should point it to the Google Drive Folder but the code you move the file to the same localpath. Here is example:

rclone move YourLocalBackupFolder googledrive:YourRemoteGoogleDriveFolder
 
Back
Top