Jump to content
Welcome to our new Citrix community!

Nightly Automated Backups with Cron - SCP config

Rob Harp

Recommended Posts

Been working on this one for a couple weeks. Hope you guys find it helpfull. I did have a bit of help from Citrix on this but not sure they would post it up.

Pre-Reqs - ssh key created and can log into destination host. There is a lot of -nix documentation on this its not hard to do.

Objective - Have nightly backups of the ns.conf file copied to server offsite via a secure method.

Disclaimer - If you are not familiar with cron and vi then please be careful. You are responsible for your own actions.

On the NetScaler appliance, the cron scheduler reads the crontab configuration file available in the /etc directory of the appliance. You cannot edit this file to schedule processes because the changes made to the file are lost as soon as you restart the appliance. However, you can use the rc.netscaler file to ensure that the configuration entries you need are added to the crontab file when the appliance restarts.

To schedule a process, complete the following procedure:

1) Create an rc.netscaler file in the /nsconfig/ directory if one is not already there.
cd /nsconfig
ls -la | grep rc.netscaler
-rw-r--r-- 1 root wheel 62 Apr 25 2008 rc.netscaler

2) Set the permissions for the file to a+x. (chmod a+x rc.netscaler)
chmod a+x rc.netscaler

3) Open the /nsconfig/rc.netscaler file in a text editor, such as the vi editor.
vi /nsconfig/rc.netscaler

4) Add your processes to the file. See example below.
echo "15 1 * root scp /nsconfig/ns.conf user@ipaddress:/tftpboot/nsconfigs/dc1-ns9000-sec-`date +\%m\%d\%y`" >> /etc/crontab chmod a+x /etc/crontab

In the preceding commands, the first line “echo” is the entry that you want to add to the crontab file. This is stored so when the Netscaler reboots it copies this back to the /etc/crontab. The order of the tabs is minutes, hours, days, weeks and months, followed by the username and the process to run at a predefined interval. In this case, the process starts at the 15th minute at 0100 every day
The second entry is to ensure that the /etc/crontab file has read and execute permissions, which by default is read after the appliance restarts.

5) Save and close the file.
hit escape button type in “wq” and hit the enter button.

6) Open the /etc/crontab file in a text editor, such as the vi editor.
vi /etc/crontab

7) Add your process to this file. See example below.
15 1 * root scp /nsconfig/ns.conf user@ipaddress:/tftpboot/nsconfigs/dc1-ns9000-sec-`date +\%m\%d\%y`

8) Save and close the file.
hit escape button type in wq! and hit the enter button.

9) In order to manually start the cron job depending on when it should run issue the following commands:
cron start
cron already running, pid: 282
kill 282
cron start
cron start again to verify its already running with new pid
cron: cron already running, pid: 18432

Edited by: rharp on Oct 20, 2011 4:32 PM

Edited by: rharp on Oct 20, 2011 9:38 PM

Edited by: rharp on Jan 27, 2012 3:06 PM

Link to comment
Share on other sites

  • 3 years later...
  • 3 years later...
  • 7 months later...


This topic is now archived and is closed to further replies.

  • Create New...