Time for action – enhancing the backup script
Open the
backupCacti.sh
script and add the following line between theFILENAME
andBACKUPDIR
line:TGZFILENAME="cacti_files_$DATE.tgz";
Add the following two lines at the end of the script:
# Create the Cacti files backup tar -czpf $BACKUPDIR$TGZFILENAME ./etc/cron.d/cacti ./etc/php.ini ./etc/php.d ./etc/httpd/conf ./etc/httpd/conf.d ./etc/spine.conf ./usr/local/spine ./var/www/html/cacti ./var/www/html/cacti-0.8.7g
Remove any earlier backups from the backup directory:
rm /backup/cacti_*
Start the backup script:
/bin/bash /backup/backupCacti.sh
Verify whether the database and the files backup have been created:
ls –l /backup
What just happened?
You have enhanced the script to also create a backup of the Cacti files. Now you can issue this single command to create a complete backup. The extra dot you have added to the paths of the tar
command will allow you to extract that tar file in a subdirectory without accidently overwriting an existing...