DirectAdmin backup as part of shell script - how can I do that

marson

Verified User
Joined
Jan 30, 2012
Messages
60
Hello

I would like to create a bash script where part of it would be to create a backup via Admin transfer / restore function of DirectAdmin from command line. So I have the following command:

echo "action=backup&append%5Fto%5Fpath=nothing&database%5Fdata%5Faware=yes&email%5Fdata%5Faware=yes&local%5Fpath=%2Fbackup%2Fdysk%5Ffull&owner=mx&select%30=dysk&trash%5Faware=yes&type=admin&value=multiple&when=now&where=local" >> /usr/local/directadmin/data/task.queue

and this command works OK, creates the backup, however it passes the command to the task.queue file so it is run from there in the background and returns to prompt immediately, the problem with this is that I want to do further actions after create the backup. So my question is how can I run backup creation directly from the script without redirection to task.queue (in foreground) so I can do next steps after backup finishes? Below I wil describe what I want to do so maybe someone will tell me the better solution?

I have couple accounts in my server, but one of the account have large directory called data under domains/mydomain.com/ so I exclude this directory from the backup by using backup_exclude_paths file. After every backup I push all *.tar.gz backup files from local directory to the remote box with rsync that data folder too separately to that remote box as well by using all_backup_post.sh script.
What I want to do is to make a full backup once a month of that account to the remote machine (with the data folder) to the separate directory) so I created the following script:

#!/bin/sh
mv /home/dysk/.backup_exclude_paths /home/dysk/.backup_exclude_paths_disabled
echo "action=backup&append%5Fto%5Fpath=nothing&database%5Fdata%5Faware=yes&email%5Fdata%5Faware=yes&local%5Fpath=%2Fbackup%2Fdysk%5Ffull&owner=mx&select%30=dysk&trash%5Faware=yes&type=admin&value=multiple&when=now&where=local" >> /usr/local/directadmin/data/task.queue
rsync -ave "ssh -p22522" /backup/dysk_full/* [email protected]:/home/backup/dysk_full
mv /home/dysk/.backup_exclude_paths_disabled /home/dysk/.backup_exclude_paths
and I will run that script once a month by cron.

however if I have prompt immediately after echo.... command the rest of this script is useless, because I don't have proper tar,gz file to rsync yet. Can anyone help me?
 
Last edited:
to execute tasks after create.
just use "/usr/local/directadmin/dataskq d200"

d200 = Log Level OUTPUT

so this solution will not work because Cronjob will execute itself in sometime.

or you just tell script to stop until found new backup gzip file with timestamp
 
Last edited:
I am trying this command:

/usr/local/directadmin/dataskq d200 "action=backup&append%5Fto%5Fpath=nothing&database%5Fdata%5Faware=yes&email%5Fdata%5Faware=yes&local%5Fpath=%2Fbackup%2Fdysk%5Ffull&owner=mx&select%30=dysk&trash%5Faware=yes&type=admin&value=multiple&when=now&where=local" instead but the backup did not create - this is the output of the above command:

/usr/local/directadmin/dataskq d200 "action=backup&append%5Fto%5Fpath=nothing&database%5Fdata%5Faware=yes&email%5Fdata%5Faware=yes&local%5Fpath=%2Fbackup%2Fdysk%5Ffull&owner=mx&select%30=dysk&trash%5Faware=yes&type=admin&value=multiple&when=now&where=local"
Debug mode. Level 200

pidfile written
starting queue
exim1: Unable to find ip_after from
exim1: Unable to find ip_after from
exim1: Unable to find ip_after from
exim1: Unable to find ip_after from
exim1: Unable to find ip_after from
exim1: Unable to find ip_after from
exim1: Unable to find ip_after from
done queue

Can you tell me what I am doing wrong?

The backup with data directory have about 200 GB so it is hard to specify reasonable timeout.
 
You wrong
You need to add queue before run dataskq
echo "action=backup&append%5Fto%5Fpath=nothing&database%5Fdata%5Faware=yes&email%5Fdata%5Faware=yes&local%5Fpath=%2Fbackup%2Fdysk%5Ffull&owner=mx&select%30=dysk&trash%5Faware=yes&type=admin&value=multiple&when=now&where=local" >> /usr/local/directadmin/data/task.queue


so tutorial is same here


Beware, dataskq is cronjob for all function of DA,
 
Last edited:
Do I understand that correct? It should look like this:

echo "action=backup&append%5Fto%5Fpath=nothing&database%5Fdata%5Faware=yes&email%5Fdata%5Faware=yes&local%5Fpath=%2Fbackup%2Fdysk%5Ffull&owner=mx&sele
/usr/local/directadmin/dataskq d200
rsync -ave "ssh -p22522" /backup/dysk_full/* [email protected]:/home/backup/dysk_full
mv /home/dysk/.backup_exclude_paths_disabled /home/dysk/.backup_exclude_paths
 
Do I understand that correct? It should look like this:

echo "action=backup&append%5Fto%5Fpath=nothing&database%5Fdata%5Faware=yes&email%5Fdata%5Faware=yes&local%5Fpath=%2Fbackup%2Fdysk%5Ffull&owner=mx&sele
/usr/local/directadmin/dataskq d200
rsync -ave "ssh -p22522" /backup/dysk_full/* [email protected]:/home/backup/dysk_full
mv /home/dysk/.backup_exclude_paths_disabled /home/dysk/.backup_exclude_paths
Yes

In your post topic, It correctly, jsut add "dataskq" to force run in current backup without to waiting cronjob
 
Back
Top