cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1732
Views
8
Helpful
17
Replies
Highlighted
Beginner

Re: CMX backup automation - FTP solution

Hello,

I am in the same situation. The script works fine when I run it but it is not running via cron. It seems to be a permission issue. 

 

How did you solve your problem?

Victor

Highlighted
Beginner

Re: CMX backup automation - FTP solution

Hello @rhobab

 

I finally wrote another script based on the one provided in this topic.

I'm executing this script in a crontab with the root user. Maybe not the best solution but this is the only working solution I found.

 

[root@cmx ~]# cat backup-cmx.sh

#!/bin/bash

PATH=/usr/local/bin:/usr/java/latest/bin:/opt/cmx/bin:/usr/pgsql-9.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

#

#<start .bashrc> pull this from the ~/.bashrc

# Auto complete files created for CMX commands, creates

# the environment to allow cmxos to run

. /etc/bash_completion.d/cmxctl.bash

. /etc/bash_completion.d/cmxha.bash

. /etc/bash_completion.d/cmxos.bash

. /etc/bash_completion.d/cmxloc.bash

 

alias cmxctl='sudo -u cmx /opt/cmx/bin/cmxctl --prompt'

alias cmxloc='sudo -u cmx /opt/cmx/bin/cmxloc'

alias cmxha='sudo -u cmxadmin /opt/cmx/bin/cmxha'

alias proxyctl='sudo -u cmx /opt/cmx/bin/proxyctl'

alias nodesetup='sudo -u cmx /opt/cmx/bin/nodesetup'

alias cmxos='sudo -u root /opt/cmx/bin/cmxos'

alias cmxverify='sudo -u root /opt/cmx/bin/cmxverify'

#

#<end .bashrc>

 

#Backup file will be saved to /tmp/

 

#Define username and password

USERNAME="xxx"

PASSWORD="xxx"

 

#Backup CMX appliance without stopping CMX services

echo "-----> Backup CMX without stopping CMX services"

cmxos backup --all --online --path /tmp/

 

#Upload backup files to remote directory via FTP

REMOTE_FTP="ftp://x.x.x.x/"

echo "-----> Remote server is: "$REMOTE_FTP

 

#Check if backup file has been created under /tmp/

echo "-----> Following backup file has been created under /tmp/: "

ls /tmp/cmx_backup_*

 

#Transfer backup file to remote FTP server

echo "-----> Backup transfer starting..."

curl -T /tmp/cmx_backup_* ${REMOTE_FTP} --user "${USERNAME}:${PASSWORD}"

echo "-----> Backup transfer ended..."

 

echo "-----> Removing local backup files to free up disk space"

rm -f /tmp/cmx_backup_*

 

echo "-----> Backup file has been locally deleted."

ls /tmp/cmx_backup_*

 

#EOF

[root@cmx ~]#

 

Sylvain.

Highlighted
Beginner

Re: CMX backup automation - FTP solution

I have been able to get it working with the other script. I scheduled it via crontab as root, then deleted the schedule and scheduled it again as cmxadmin and it started working. 

Content for Community-Ad
Cisco Community July 2020 Spotlight Award Winners