Backup script

Arieh

Verified User
Joined
May 27, 2008
Messages
1,127
Location
The Netherlands
I want to make daily admin backups and upload them to 1 or more ftp servers. First I just configured the cron to make a admin backup to a remote ftp server, but as I wanted the files on the DA machine itself + multiple ftp servers I can't do it like this anymore.

What I've tried to do is making admin backups just localy to /home/admin/admin_backups and running another script about one hour later to upload the backups to my ftp server. I made a little php script with some basic ftp_put functions (because php is about the only language I can write in) but I noticed it slows things down.

DirectAdmin's backup to ftp totally takes only 15 minutes, mine one hour.

Today's local backup took 6 minutes, so I take it DA's ftp transfer takes about 10 minutes.

Could using php be so much slower? If so, does anyone have a script in another language willing to share? :) Any other suggestions are also welcome.
 
As I understand it, DA makes the backup and directly uploads it to FTP, and its gone. I want it locally and from there to multiple locations.
 
What is wrong with uploading to itself? The ftp server would be 127.0.0.1.

To solve multiple locations you can create multiple cron jobs.

No its not the most efficient but it does work without making any modifications or custom scripting.
 
Well ftping to localhost would be the same as just a normal local backup in /home/admin/admin_backups, I was trying to make the backups themselves one time and go further from there to save the backup resources. I could make multiple ftp crons but that would mean for each cron it makes new backups.

What I would like is:
1 DA cron which makes a local backup
x crons to distribute them trough some ftp script.
 
Looks interesting, though I'm not sure whats going on here.
It says that it uses php, and it might have a .php extension but it actually is a sh file lol

It uses /usr/bin/ncftpput, I'm gonna try to make a script based on that /usr/local/directadmin/scripts/ftp_upload.php file. Thanks
 
Well here it is :) my very first sh script. It uploads all .tar.gz files in the configured local path to the remote path with the configured ftp settings.

If you want to upload the backups to a remote path with the current date, use the following setting for FTPPA. It will create a dir like 08-16-2010 in / and uploads everything there.

Code:
FTPPA="/$(date '+%d-%m-%y')"


Code:
#!/bin/sh

# Remote ftp server
FTPH="remoteserver.tld"

# Remote ftp user name
FTPU="yourusername"

# Remote ftp user password
FTPP="yourpassword"

# Remote ftp path
FTPPA="/"

# Local path
LOCALPATH="/home/admin/admin_backups"

FTPPUT=/usr/bin/ncftpput

if [ ! -e $FTPPUT ]; then
        echo "";
        echo "*** Backup not uploaded ***";
        echo "Please install $FTPPUT by running:";
        echo "";
        echo "cd /usr/local/directadmin/scripts";
        echo "./ncftp.sh";
        echo "";
        exit 10;
fi

for file in $LOCALPATH/*.tar.gz
do
  echo `date` "- Uploading $file";
  $FTPPUT -V -t 25 -m -u "$FTPU" -p "$FTPP" "$FTPH" $FTPPA "$file"
done

date

exit 0
 
Last edited:
Back
Top