Elastix backup using cron

Discussion in 'General' started by syvox, Feb 4, 2009.

  1. syvox

    Joined:
    Nov 26, 2008
    Messages:
    6
    Likes Received:
    0
    Hi!

    I am wondering or better hoping - somebody has a clue to backup the elastix system (DB and Data) by a simple little cron job.
    It is not very easy for me to push the button every night on the backup web-page for doing so.

    Is there a solution like it has freepbx ("pseudo"cron on the freepbx webpage?).

    Thankx in advance

    Syvox
     
  2. Redfone

    Joined:
    Jul 12, 2007
    Messages:
    177
    Likes Received:
    0
    This is a good idea. I think a Backup/Restore "Scheduling" option in the module would be the most elegant solution.

    In the meantime, if you want to put together your own solution it would appear all of the necessary scripts can be located in this directory;
    /var/www/html/admin/modules/backup

    You may be able to go through this directory and figure out how to make your own cron-able script that does what you need.

    Good luck!
     
  3. wiseoldowl

    Joined:
    Aug 19, 2008
    Messages:
    251
    Likes Received:
    0
    I created a directory called backup and the twice a week I run this script:

    cd /backup
    mv fullbackup.tgz fullbackup.tgz.bu
    tar --exclude /var/spool/mail/admin -czf /backup/fullbackup.tgz /usr /var /etc /bin /dev /home /sbin /lib /root /tftpboot /boot

    This excludes the mail spool (generally full of useless server messages that nobody reads) but backs up everything else in the listed directories (/usr /var /etc /bin /dev /home /sbin /lib /root /tftpboot /boot). There are always two backups available, the most recent, and the one previous to that.

    I used Webmin to set up a schedule to run the script on Monday and Friday mornings in the early AM hours. I then have script running on a different box that comes in later in the morning and copies the two backup files to a different computer.

    Not saying this is the best way, just that it makes me feel a bit more secure. Of course, if some error creeps in and I don't catch it in two or three days I might have a problem, but I really don't want a bunch of old backups.

    What the Linux folks need to come up with is something similar to the Mac's "Time Machine" program!
     
  4. ramoncio

    Joined:
    May 12, 2010
    Messages:
    1,663
    Likes Received:
    0
    wiseoldowl, you don't backup the mysql databases! This is important!!

    This is what I do in my cron job:

    Code:
    mkdir /root/asterisk.backup-`date +%Y.%m.%d`
    tar cfvz /root/asterisk.backup-`date +%Y.%m.%d`/elastix-`date +%Y.%m.%d.%H.%M.%S`.tgz /var/www/ /etc/httpd/ /etc/asterisk/ /var/lib/asterisk/sounds/ /var/spool/ 
    mysqldump -uroot -h localhost -peLaStIx.2oo7 asterisk | gzip -9 > /root/asterisk.backup-`date +%Y.%m.%d`/asterisk-`date +%Y.%m.%d.%H.%M.%S`.sql.gz
    mysqldump -uroot -h localhost -peLaStIx.2oo7 asteriskcdrdb | gzip -9 > /root/asterisk.backup-`date +%Y.%m.%d`/asteriskcdrdb-`date +%Y.%m.%d.%H.%M.%S`.sql.gz
    
    In the tar line you can add or remove whatever you want to be backed up.
    I delete old backups manually. Maybe I'll find a solution to do it all automatically.
     
  5. ramoncio

    Joined:
    May 12, 2010
    Messages:
    1,663
    Likes Received:
    0
    I don't know why this forum software breaks the lines in the code!!!
    This should be fixed with the highest priority!!
    Take note, Rafael.
     
  6. wiseoldowl

    Joined:
    Aug 19, 2008
    Messages:
    251
    Likes Received:
    0
    I somehow doubt that the database is not included in the directories that I'm backing up.

    I had typed a longer message in response but it was lost because of tbhe f---ing short timeout on this system before you have to re-register. One of these days when that happens I'm really going to go off so whoever runs this forum had better either fix the timeout or ban me for life, because I get REALLY angry once I have worked on a post for 20 minutes and the forum software loses it because it is so anal about security. At least you should wait an hour before de-registering someone, right now it seems like five or ten minutes.

    Seriously, you need to either fix this or ban me, otherwise don't be surprised if you get a profanity-laced message one of these days. I'm still upset about the irresponsibility of the Elastix developers that I wrote about in this post - yeah, I know that was six or seven months ago, but I'm reminded of it every time this forum eats one of my posts!

    At lead the code formatting thing usually only happens in preview (although the problem is that even though it displays the code block correctly, it eats paragraph breaks AFTER the code block in the published article).
     
  7. syvox

    Joined:
    Nov 26, 2008
    Messages:
    6
    Likes Received:
    0
    The solution for this problem is to start the following line as a cronjob anytime you want ;-)

    Code:
    find /var/backups/elastix -mtime +8 | xargs rm 
    - mtime +X is the important "key" for this problem - in my example all files - oder than 8 days (important - this counts hours not exactly days!) - will be deleted.

    Hope this helps

    thankx for your answers...
     
  8. ramoncio

    Joined:
    May 12, 2010
    Messages:
    1,663
    Likes Received:
    0
    Thanks!
    This is nice!
    I take note.
     
  9. dicko

    Joined:
    Oct 24, 2008
    Messages:
    4,099
    Likes Received:
    0
    syvox:

    With respect, might I note your typo. and suggest

    Code:
    find /var/www/html/backup/elastix* -mtime +8 | xargs rm
    would be more effective in a standard Elastix installation.
     
  10. dicko

    Joined:
    Oct 24, 2008
    Messages:
    4,099
    Likes Received:
    0
    wiseoldowl:

    A comment,
    I believe we are all frustrated with this software, sometimes action is better than anger so :p , but also ;) .
    (Kudos to Chill for his proactivity.)

    regards,

    Dicko


    (I do note the timestamp of your post however)
     

Share This Page