Environmental variables for ftp_upload.php


Enter Your Query:
Use '%' for wildcards and quotes for "exact phrases"


Top Level » DirectAdmin » Backup & Restore Process

Environmental variables for ftp_upload.phpLast Modified: Feb 18, 2015, 4:38 pm
If you're making custom changes to the ftp_upload.php, you'll want to know all the variables you get to play with.
Below is a sample list of variables and values for a cron ftp backup, with ID number 1, for a single selected testuser:

action=backup
append_to_path=nothing
database_data_aware=yes
dayofmonth=5
dayofweek=*
email_data_aware=yes
ftp_ip=127.0.0.1
ftp_local_file=/home/tmp/admin/user.admin.testuser.tar.gz
ftp_local_path=/home/tmp/admin
ftp_password=password
ftp_path=/admin_backups
ftp_port=21
ftp_remote_file=user.admin.testuser.tar.gz
ftp_username=admin
hour=5
id=1
minute=0
month=1
owner=admin
select0=testuser
type=admin
value=multiple
when=now
where=ftp



This output was generated by doing:

cd /usr/local/directadmin/scripts/custom
cp /var/www/cgi-bin/printenv ftp_upload.php
echo "exit 1;" >> ftp_upload.php
chmod 755 ftp_upload.php
./ftp_upload.php    #just to test

In my case, I did need change the 1st shebang line of the file from #!/usr/local/bin/perl to #!/usr/bin/perl, but you may already have the perl binary.

Once created, run your desired backup with ftp, and it will throw an error, and you'll then see all the variables you get for that backup.  Delete the custom ftp_upload.php, and create your own (or copy the default value from one directory above).



THe typical need for this would be if you want different backup IDs to take a different action.  Say you want backup ID 1 to be uploaded via scp rather than ftp, this would let you add a line:

if [ "$id" = "1" ]; then
   #scp upload code
   exit 0;
fi

before the ftp section.. so ID 1 uses scp, and everything else uses ftp (just as an example)
You can also do any check on any other variable, like username, password, remote IP, path, etc..

Note, if you use "When: Now", then no "id" will be passed.
But if you select an existing cron backup, and click "Run Now" for the existing cron ID, the id will be passed.

 
Related Helpfiles
How to convert ftp_upload.php to use ncftpput or curl instead of php
Manually testing the ftp_upload.php script

© 2018 JBMC Software, Suite 173  3-11 Bellerose Drive, St Albert, AB  T8N 1P7  Canada.  Mon-Fri 9AM-5PM MST