backup_ast 1.0 - Easy Asterisk config file backups

As an Asterisk administrator, I'm working with config files all the time. Any work involving the phone system involves modifying a configuration file and then reloading that part of Asterisk. Before making changes, it's important to make a backup copy of the file just in case. I got tired of always typing cp /etc/asterisk/filename.conf /etc/asterisk/backup/filename.conf.201205092008 so I wrote a script that will ease in backing up either a configuration file, all of them, or a group of them, such as DAHDI.

You can find the script here:
http://pastebin.com/x9BiPmvG

Once you download the script, I recommend putting it somewhere in /usr/local/bin/, making it executable, and then running it with the -h flag to see some usage examples.

Please feel free to post with any questions. The script doesn't do much error checking as it doesn't make any changes to any files. It just checks that the backup directories are indeed available. I tried really hard to catch every possible case, but if you think of one I missed, please feel free to share and I'll quite possibly add it.

2117 views and 1 response

  • May 9 2012, 9:50 PM
    Zack responded:
    Why not shove the whole config directory in version control? That could be sent off-server via SSH as backup and give you per-file diff, change history, and a log of changes.