Re: Scripting the deletion of old backups for OpenNMS
"Courtney, Wrolf" <[email protected]> Tue, 6 Jan 2015 20:31:13 +0000
| Newsgroups | gmane.network.opennms.install |
|---|---|
| Message-ID | <C22DA43300E0E24F8BCA9A53CE460F2E24112ADC@NYCT2BWYEXMB01.transit.nyct.com> |
Try putting this script in your /etc/cron.daily directory. This will run it as root once per day. Wrolf From: Brasted, Dominic [mailto:[email protected]] Sent: Tuesday, January 06, 2015 2:43 PM To: Installation questions and help Subject: [opennms-install] Scripting the deletion of old backups for OpenNMS Hi, I've used the OpenNMS wiki to put together a script to run backups of OpenNMS and then delete any old backups older than 30 days, but I can't find how to run the deletion command without sudo credentials. As it stands, I'm pretty sure the script will halt at the point it tries to delete the files, as I'm deleting out of the /opt folder. I have the same problem if I create my backup directory in the /mnt folder as per the wiki. Is it possible to "force" the command so it doesn't require user input? The script is going to be called by our backup system before it performs the server filesystem backup. #!/bin/bash # Create timestamp dsig=`date +%Y%m%d` # Back up Postgres DB pg_dump -U opennms -Fc -f /opt/opennms/backup/$dsig-database.pgsql.gz opennms # Delete all backups older than 30 days find /opt/opennms/backup -name '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]*.gz' -mtime +30 -delete Your assistance is much appreciated. I've had difficulty finding an answer online. Regards, Dominic ------------------------------------------------------------------------------ Dive into the World of Parallel Programming! The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net _______________________________________________ Please read the OpenNMS Mailing List FAQ: http://www.opennms.org/index.php/Mailing_List_FAQ opennms-install mailing list To *unsubscribe* or change your subscription options, see the bottom of this page: https://lists.sourceforge.net/lists/listinfo/opennms-install