bar top left
bar top right
left curve
right curve
Welcome, Guest
Go to bottom
Post Reply
Post New Topic
Page: 123
TOPIC: Scheduling Backups
*
#24469
Scheduling Backups 2 Years, 8 Months ago Karma: 2
At my work we have just recently started using Elastix, switched from trixbox mainly because the backup module that Elastix has is much more robust and covers almost all the configuration of the server. The only problem is that it doesn't have any way to schedule backups. Freepbx does have a backup module with scheduling, but its backup doesn't cover all the services and configurations that the backup module does.

Originally I was going to just make a cronjob that sent the html POST to the backup module to tell it to make a backup, but after looking into that and the amount of data I'd have to send to trigger a full backup, I shelved that idea.

Instead I've written a perl script that does basically the same thing as the backup module that comes in Elastix, except of course you can run it from the command line instead of having to use the web interface. This makes it possible to put it in a cronjob or anything else to have regular backups created automatically. The files made can be selected and restored via the web interface.

Please note there's not a lot of error correction in this script. If commands fail it probably isn't going to tell you about it. It's the first revision and I'll be making a better version in the future, but for now it works and is running on my system. I thought it might be useful to others so I am posting it.

-Marie
File Attachment:
File Name: backup.tgz
File Size: 2267
Enter code here   
Please note: although no board code and smiley buttons are shown, they are still usable.
mkoreen
Fresh Boarder
Posts: 7
graphgraph
User Offline Click here to see the profile of this user
Reply Quote
 
#26023
Re:Scheduling Backups 2 Years, 8 Months ago Karma: 0
Thank you very much, I was searching for this and will give it a try later.

This feature, should be integrated into Elastix, I think it is a very usefull option.

And after this, uploading the whole backup file to a remote location via FTP or so should be also integrated, so you can have periodic full backups or your customers PBX´s and could supply a fast replacement HDD or full machine for minimum down-time.

I´ll try your script and combine it with a FTP upload script and see what happen.

Best regards !
Enter code here   
Please note: although no board code and smiley buttons are shown, they are still usable.
hpwr
Fresh Boarder
Posts: 17
graphgraph
User Offline Click here to see the profile of this user
Reply Quote
 
#26173
Re:Scheduling Backups 2 Years, 8 Months ago Karma: 0
If you could post some step by step for newbies like me if im the only newbie here then for me please
Enter code here   
Please note: although no board code and smiley buttons are shown, they are still usable.
raj
Senior Boarder
Posts: 133
graphgraph
User Offline Click here to see the profile of this user
Reply Quote
 
#26196
Re:Scheduling Backups 2 Years, 8 Months ago Karma: 2
Instructions:

1. Untar the script.
2. Put it somewhere on the host.
3. Edit the file and change any configuration options that you want to change.
4. Edit /etc/crontab and add a line like the following:

02 3 * * * root /root/backup.pl

That would make it do a backup at 3:20am every day.
Enter code here   
Please note: although no board code and smiley buttons are shown, they are still usable.
mkoreen
Fresh Boarder
Posts: 7
graphgraph
User Offline Click here to see the profile of this user
Reply Quote
 
#26299
Re:Scheduling Backups 2 Years, 8 Months ago Karma: 0
Hello !

I´ve tested some things and the script is working good so far, I´ve added some lines to the script to upload the resulting file to a FTP server, and also changed the filename including the machine hostname for better orgasnisation on the ftp-server.

I don´t know much about programming languages so I used the c&p method

Here the instrucions I wrote and used;

1: Install wPut ( wput.sf.net )
# wget freefr.dl.sourceforge.net/sourceforge/wput/wput-0.6.1.tgz
# tar -xzf wput-0.6.1.tgz
# cd wput-0.6.1
# ./configure; make
# make install

2: Configure Hostname
# vim /etc/sysconfig/network

NETWORKING=yes
HOSTNAME=elastix-name
GATEWAY=192.168.0.1

# hostname elastix-name

3: Edit backup.pl and edit your FTP server information...
my $ftp_destination = 'ftp://usuarname:password@server:port';

4: Copy backup.pl to your elastix machine ( /root/autobackup/ for example) (WinSCP, wget or whatever you like..)

5: Give the script execution rights:
# chmod 770 backup.pl

5: Try
# ./backup.pl

...
backup/mysql_mysql.tgz
backup/vtigercrm503_mysql.tgz
backup/tftpboot.tgz
backup/fax.db
--12:36:44-- `/var/www/html/backup/backup-elastix-name-20090609123355-99.tar'
=> ftp://usuario:xxxxx@100.100.100.100:21//var/www/html/backup/backup-elastix-name-20090609123355-99.tar
Connecting to 100.100.100.100:21... connected!
Logging in as usuario ... Logged in!
Length: 455,424,000
2% [===> ] 13,370,368 229.8K/s ETA 31:18m
...


6: Programming CRONjob for automated backup once a week (in my case)
# cp backup.pl /etc/cron.weekly/
# vim /etc/crontab

45 12 * * 2 root run-parts /etc/cron.weekly

(12:45 every THU (second week-day))

7: See if everything work
# tail /var/log/
Jun 9 12:48:02 elastix crond[13906]: (root) CMD (run-parts /etc/cron.weekly)

# ls -lah /var/www/html/backup

Look at your FTP server if the file is incomming




Best regards !
Enter code here   
Please note: although no board code and smiley buttons are shown, they are still usable.
hpwr
Fresh Boarder
Posts: 17
graphgraph
User Offline Click here to see the profile of this user
Last Edit: 2009/06/09 06:43 By hpwr.
Reply Quote
 
#26300
Re:Scheduling Backups 2 Years, 8 Months ago Karma: 0
I forgotten to upload the moddified script, couldn´t edit the above post...

Also, I must comment about my problem, the script work perfect, doing the backup and uploading to my server,
but the CRONjob only do the backup, but don´t upload the file. I find it strange, why is the script not doing all the work when executing by cron.d ? Any ideas ?

Regards !
File Attachment:
File Name: backup.gz
File Size: 2240
Enter code here   
Please note: although no board code and smiley buttons are shown, they are still usable.
hpwr
Fresh Boarder
Posts: 17
graphgraph
User Offline Click here to see the profile of this user
Reply Quote
 
#26348
Re:Scheduling Backups 2 Years, 8 Months ago Karma: 2
You may have to specify full path for your wput command in the script. In general cron uses a pretty thin path, and probably won't find anything in /usr/bin or /usr/local/bin. I believe it just uses /bin:/sbin as it's path. So put in the full path of wput in the script and you should be good. For reference tar works because it's in /bin/tar.

-Marie
Enter code here   
Please note: although no board code and smiley buttons are shown, they are still usable.
mkoreen
Fresh Boarder
Posts: 7
graphgraph
User Offline Click here to see the profile of this user
Reply Quote
 
#26401
Re:Scheduling Backups 2 Years, 8 Months ago Karma: 0
Hi, I had this idea yesterday but seeing tar without path I thought it must work

I´ve added the full wput path and now everything work perfect !

backup.pl:
Code:


 system("/usr/local/bin/wput -t 10 $ftp_destination $backup_destination/backup-$hostname-$timestamp.tar") == 0



I´ve created a direct line in crontab for simplyfying things, without copying anything into /etc/cron.weekly/

/etc/crontab:
Code:

# Weekly Backup every Friday at 23:30
30 23 * * 5 root /root/autobackup/backup.pl



The next thing should be integrating the Scheduled backups (and upload possibility..) into the Management web from elastix, but this is up to the devs

Thank you.
File Attachment:
File Name: backup-6e5d04b60298e884910be9e91009e9f1.gz
File Size: 2348
Enter code here   
Please note: although no board code and smiley buttons are shown, they are still usable.
hpwr
Fresh Boarder
Posts: 17
graphgraph
User Offline Click here to see the profile of this user
Reply Quote
 
#26424
Re:Scheduling Backups 2 Years, 8 Months ago Karma: 0
That's a great looking backup script. Has anyone tried anything using Links hidden for unregistered users. Login or register Here (open source auto-rotating backup system? To me, the key to backups is to automate how many backups one has and to reduce the amount of bandwidth required to move them around.

Just a thought...
Enter code here   
Please note: although no board code and smiley buttons are shown, they are still usable.
izrunas
Open Source Fanatic
Junior Boarder
Posts: 89
graphgraph
User Offline Click here to see the profile of this user
Gender: Male eriks.goodwin UniMatrix xSP izrunas Location: Richmond, Virginia, USA Birthday: 03/19
Eriks Goodwin-Pfister, Links hidden for unregistered users. Login or register Here & Links hidden for unregistered users. Login or register Here
Reply Quote
 
#31079
Re:Scheduling Backups 2 Years, 6 Months ago Karma: 0
I noticed when I compare the backup created using this script and the backup created inside elastix.

What is the difference between the two backups? I checked the files inside the backup and there is a difference between the two.

Thanks
-Kyle.
Enter code here   
Please note: although no board code and smiley buttons are shown, they are still usable.
kitzul
Fresh Boarder
Posts: 2
graphgraph
User Offline Click here to see the profile of this user
Reply Quote
 
Go to top
Post Reply
Post New Topic
Page: 123
Moderators: Bob, jgutierrez