daily backup

37
PBX IN A FLASH DEVELOPMENT CORPORATION Daily Backup Backing up your PBX in a Flash 1.7.5.5 installation on a daily basis PIAF Development Corporation Mar 25, 2011 A manual to install, configure, and use a daily backup program on PBX in a Flash 1.7.5.5

Upload: rodney-coleman

Post on 26-Mar-2015

105 views

Category:

Documents


7 download

TRANSCRIPT

Page 1: Daily Backup

PBX IN A FLASH DEVELOPMENT CORPORATION

Daily Backup Backing up your PBX in a Flash 1.7.5.5

installation on a daily basis

PIAF Development Corporation

Mar 25, 2011

A manual to install, configure, and use a daily backup program on PBX in a Flash 1.7.5.5

Page 2: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 2

Welcome! This document will describe the configuration and installation of the daily backup package onto PBX in a Flash 1.7.5.5 We have tested this script on Lab, Production, Real, and Virtual machines; using both VMware and Proxmox with great success. This is version 1.7.5.5 of the program released March 25, 2011

WARNINGS

As with any new piece of software you need to ensure it actually works in your own computer environment. If you fail to test this software on your production machine and you rely on it to do mission critical backups YOUR BACKUP OR RESTORE WILL FAIL. What does this mean? It means that without testing on your own hardware the Daily Backup program may not work at all.

This work is copyright 2007 – 2011 by the PBX in a Flash Development Corporation. This work may not be altered or modified without express written permission of the author. You may copy this manual and use it freely; however this notice must be included with the document. This manual is NOT released under the GNU General Public License. Whole Disk Backup is designed and licensed to only run under PBX in a Flash. Use of this program under any other PBX system is a violation of our license.

Please contact us in the PBX in a Flash forum for further information.

Page 3: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 3

The need to have software backups on a daily basis is a requirement that has been lacking in most installations of PBX systems. When a PBX installation fails due to software problems there has to be a way to quickly and accurately repair or restore the errant piece of software. To this end a daily backup program was created. This program is run by cron every morning about 4am and will make backups, using various methodologies, of critical files that are essential to running PBX in a Flash 1.7.5.5. Once these backup procedures have been completed a single master archive will be created and then optionally move offsite. Upon completion a complete report will be emailed to the user of your choice.

OVERVIEW

Daily-backup also offers the ability to move the master archive to offsite storage via FTP, SMB, Attached USB flash/hard drive, and copy to a Pogo Plug. Rsync is also supported for selected transport mechanisms.

The “Kitchen Sink” approach was chosen to make daily backups as opposed to a single method of storing critical system information. This provides the user with extra flexibility when it comes to restoring critical aspects of PIAF 1755 where a complete bare metal restore may NOT be required. For example: a single table in MySQL becomes corrupted you can simply restore from the MySQL dump which is stored in the master archive.

METHODOLOGY

Once you have configured the /etc/pbx/daily-backup.conf file cron will run /etc/cron.daily/disk-backup.cron at about 0400 hours. The program will read the configuration file and proceed to call various backup methods and then store the results in a single master backup file. The current methods for backing up PBX in a Flash 1.7.5.5 are: Original FreePBX backup, Complete dump of MySQL, Incredible backup, and a separate archive of any digium licenses.

In order to restore please follow the appendixes in the back of this document. NOTE: Some of these appendixes have yet to be written and require a high degree of Linux awareness. Unfortunately this is beyond the scope of this manual.

Page 4: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 4

There are several requirements to run the disk backup script and they are outlined below. It is recommended you have met all of the requirements prior to performing the installation and configuration.

REQUIREMENTS

o A working PBX in a Flash 1.7.5.5 installation. Note this software is designed to work with PBX in a Flash 1.7.5.5 ONLY

o A command line editor you are comfortable with on your PBX in a Flash. We use joe as our command line editor.

o Various pieces of information that you will require in order to make the file transfer methods you have selected work. Below is a table of all of the required information. Simply fill the information for the method of storage you have selected. By default ftp is enabled and USB/SMB is disabled.

A least one of the following

o An ftp account on a remote system that you can log into and upload files

o A USB stick of sufficient size locally attached to your PBX in a Flash. It is recommended you follow the directions in Appendix one to delete the existing file system and redo it with the Linux version of fdisk and mkdosfs.

o Access to a shared drive on a Windows/Samba server with sufficient privileges to read and write files

o Access to a Pogo Plug share

Page 5: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 5

These settings are contained in /etc/pbx/daily-backup.conf and /etc/pbx/script-email.conf. When the program is installed the default setting is to disable daily backups until the /etc/pbx/daily-backup.conf file is fully configured.

Information Tables to be filled out prior to Installation

Configuration Options

VARIABLE NAME

Default Value User provided

value Description

CONFIGURED “0”

MASTER SWITCH This controls if the program is processed.

0 = DISABLED You need to change this to “1” after you have configured the /etc/pbx/disk-backup.conf file

VARIABLE NAME

Default Value User provided

value Description

SENDLOG “1”

This switch instructs the program to email the log file to a email address specified in /etc/pbx/email-script.conf There is another option later in the configuration file to gzip the log file prior to sending it.

0 = Do not email log

1 = Email log

DELBACKUPS “1”

This option causes the ISO files that have been created to be deleted AFTER they have been copied to offsite storage.

0 = Do not delete local copy of ISO file

1 = Delete local copy of file

DIRECTORY “/backup” Do not change! This is where the ISO files are created.

Page 6: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 6

Incredible Backup Configuration

VARIABLE NAME

Default Value User provided

value Description

IBACK “1”

This option tells the program to process a daily backup via the Incredible Backup methodology

0 = Do not use Incredible Backup

1 = Use incredible Backup

MySQL Database backup

VARIABLE NAME

Default Value User provided

value Description

DBBACK “1”

This option tells the program to perform a MySQL dump of all tables

0 = Do not use the MySQL dump procedure

1 = Use the MySQL dump procedure

DBNAME “root” DO NOT CHANGE

Should not have to be changed

DBPASS “passw0rd” DO NOT CHANGE

Should not have to be changed

Page 7: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 7

FreePBX Backup

VARIABLE NAME

Default Value User provided

value Description

FPBXBACK “1”

This option tells the program to perform a FreePBX Backup of the system

0 = Do not backup the system using the freepbx method

1 = backup the system using the freepbx method

REMFILES “1”

This option removes the freepbx generated archive located in /var/lib/asterisk/backups/piafbackup

0 = Do not remove files

1= Remove files

Options See Appendix This allows you to specify what the FPBX program will backup. See the file for details. Do not modify unless you know what you are doing.

VARIABLE NAME

Digium License Backup

Default Value User provided

value Description

LICBACKUP “1”

This option tells the program to copy any Digium license located in /var/lib/digium

0 = Do not backup Licenses

1 = backup Licenses

DIGIUMLIC "/var/lib/digium" DO NOT CHANGE UNLESS YOU KNOW WHAT YOU ARE DOING! This is the path currently to where the digium licenses for thing like g729… are stored

Page 8: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 8

Ftp Information

VARIABLE NAME Default Value User

provided value

Description

CPFTP “0”

Once the ISO’s have been created by Mondorescue copy them to an ftp store

0 = Do not copy to ftp share

1 = Copy to ftp share

USERNAME “ftpuser” This is the username that you use to log onto the remote ftp server

PASSWORD “ftppassword” This is the password used to log onto the remote ftp server

REMOTEDIRECTORY “/” This is the remote ftp directory you wish the backup files to be placed minimum is /

SERVER “ftp.server.ip” This is the IP address or Fully Qualified Domain Name of the ftp server

Page 9: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 9

Usb drive info

VARIABLE NAME Default Value User provided

value Description

CPFLASH “0”

Once the ISO’s have been created by Mondorescue copy them to an external USB Hard/Flash drive

0 = Do not copy to USB hard/flash drive

1 = Copy to USB hard/flash drive

USBMOUNTPOINT= “/mnt/usbmondo” Where the flashdrive is mounted to default is /mnt/usbmondo

It is recommended

you DO NOT change this

USBDEVICENAME= “/dev/sda1”

This is the device name of your USB stick and may change depending on what you find using dmesg. Default is /dev/sda1 *Usually works in most cases

Please see Appendix one for the complete procedure to configure your USB drive to work before filling out the table above.

Page 10: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 10

Smb Share Information

VARIABLE NAME Default Value User provided

value Description

CPSMB “0”

Once the ISO’s have been created by Mondorescue copy them to a SMB share on the network

0 = Do not copy to network share

1 = Copy to network share

SMBMACHINE= “192.168.1.5”

This is the ip Address of the machine that is sharing a folder. This machine can be windows based or any operating system that can run SAMBA server

SMBSHARE= “sharename”

This is the share name on the remote window/Samba machine. NOTE you must have sufficient privileges on the remote machine to read/write/modify

LOCALMOUNT= “/mnt/smbmondo” This is the local folder that the remote SMB share is mounted to. NOTE don’t change thus unless you understand how.

It is recommended you DO NOT

CHANGE THIS!

SMBUSER= “user” This is your username on the remote Windows/Samba machine

SMBPASS= “pass” This is your password on the remote Windows/Samba machine.

Page 11: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 11

VARIABLE NAME

Pogo Plug Information

Default Value User provided

value Description

CPPOGO “0”

Once the ISO’s have been created by Mondorescue copy them to a network based Pogo Plug

0 = Do not copy to the Pogo Plug

1 = Copy to the Pogo Plug

PMOUNT "/mnt/pogoplug" This is the local mount for Pogo Plug It is recommended you do NOT change this

PNAME "[email protected]" This is the username to log into a Pogo Plug. Note it should be in the form of an email address

PPASS "password" This is password used in conjunction with username to log into a Pogo Plug

POGOROOT "16gbflash"

This is the name of the hard drive on the Pogo Plug you wish to use. NOTE it is recommended you change the name of the shared hard drive to something without spaces in it. Spaces in the hard drive name can lead to unexpected results. This can be changed on the web based configuration # my.pogoplug.com

POGOPATH "test 15"

This is the destination directory on the Pogo Plug. If it does not exist it will be created. We tested it with a space in the name however it is recommended you do NOT use spaces or any special charaters in the directory name

Page 12: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 12

Rsync information

VARIABLE NAME Default Value User provided

value Description

USYNC “0”

This will allow the ISO files to be copied to the destination via rsync. Generally this takes less time to do the copy, except for the first iteration. After the first time only the deltas (changes) are copied to the remote storage device.

If enabled it will be used on all enabled methods except for ftp.

0 = Do not use rsync

1 = Use rsync

Gzip information

VARIABLE NAME Default Value User provided

value Description

GZIPPEE “0”

With this option gzip will compress the log file prior to emailing it to the designated recipient. The log files can become very large and be rejected by mail servers. This is only effective if sending of logs via email is enabled (as above)

Page 13: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 13

Email configuration

The configuration of sending automated emails for log files was moved to a separate configuration file. Many of PIAF support programs now use this file in order to ascertain if log files are to be sent and to whom the email goes to. This file now resides in /etc/pbx and is called script-email.conf

VARIABLE NAME Default Value User provided value Description

EMAIL= “root@localhost”

Place your own email address here, enclosed in double quotes. If you leave it the default it will send the log files to the root account.

USEEMAIL “1”

With this setting you can tell the application to always send a copy of the logs to the addressee.

0 = Do not email the logs

1= Send the application logs via email.

NOTE This feature will only work if you have your sendmail/postfix configured to send email outside of your PBX in a Flash system. Please don’t ask for help on configuring your sendmail/postfix. You must test your sendmail/postfix install by sending a test message outside of your PBX in a Flash system.

Page 14: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 14

In order to install daily-backup.cron and its associated programs the user will have to follow some basic commands in the PBX in a Flash 1.7.5.5 command line interface. (Hereinafter called the CLI) This document contains screen captures and step by step instructions so the installation should not present too many difficulties.

PROCEDURE

The general order of installation is as follows:

1. Decide which method(s) you will be using to transfer your backup files and to which remote machines or attached devices. You may choose one or all of them. By default ftp is enabled but you can also choose to use USB hard/flash drive, SMB, or Pogo Plug.

2. Fill out the information tables above prior to installing the software. If you are going to use a USB memory stick I recommend it be at least 8gb in size. You will need to follow the steps in Appendix 1 in order to get the required information to fill out the table above.

3. Install the Software

4. Configure the /etc/pbx/daily-backup.conf file.

5. Test the backup software by running the daily-backup.cron script by “hand”. This may take a while. Start it running and go away for lunch!

Page 15: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 15

Please log onto your PBX in a Flash 1.7.5.5 system as root and perform the following steps

INSTALLING THE SOFTWARE

STEP 1

Type help-pbx and then tap the ENTER key

As you scroll through it you will see on page 3 the new install-dailybackup program

Page 16: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 16

STEP 2

Type install-dailybackup and then tap the ENTER key. You will see out standard license screen tap the Y key to agree with the terms and continue

You might see the following screen if the mail configuration file is not present on the system

Page 17: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 17

STEP 3

Next you will see the download screen

If the download is successful you will see the install proceed. If your internet is down you will see the following

Then

If you see these screens you have problems with your internet connectivity. It is your problem to diagnose this and not the developers of PBX in a Flash!

Page 18: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 18

STEP 4

As the install progresses you will see the following screens:

Page 19: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 19

Other screens that may be displayed

If you see this screen it means you are trying to run this program on a non PBX in a Flash 1.7.5.5 installation or you are trying to run it on a pre PBX in a Flash 1.7.5.5 install. Unfortunately older installs of PIAF are incompatible with the new version of the program. If you are running an older version of PIAF please use the deprecated version as it still works. There are NO plans to back port this version so it runs in versions prior to 1.7.5.5

Page 20: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 20

We need to edit the /etc/pbx/daily-backup.conf file and add the appropriate information. We recommend the use of joe for this purpose. It is a powerful text editor and allows you to use the WordStar commands . All of the following screen captures are show inside of the joe editor environment.

Configuring the daily-backup.conf file

Log into your PBX in a Flash 1.7.5.5 system as root and in the CLI type cd /etc/pbx and tap the ENTER key. Now type joe daily-backup.conf and then tap the ENTER key. You should see the screen below.

A few notes about the disk-backup.conf

• The can be no blank lines! Comments always start with a # symbol

• All options MUST be enclosed by double quotes for example: “1”

• There are NO capital O’s as options only Zeros 0

1. The first thing to edit is the master switch. This controls if the conf file is processed. It is shipped OFF

Page 21: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 21

2. Next we edit the configuration options

We recommend you use the defaults

3. Incredible Backup configuration – There is only one option to use it or not.

4. MySQL Dump configuration – There are 3 options. The first is to use this backup method. The default is set to yes. The other 2 options are related to username and password for MySQL. If you have not changed this then the defaults will do nicely. There is no reason to change the MySQL password as MySQL is not accessible except through the local console.

Page 22: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 22

5. FreePBX configuration – There are multiple options and we recommend you leave the defaults alone. The primary one is FPBXBACK which tells the program to use the FPBX backup method. The options flag allows you to choose what you want FPBX to backup. The default is to backup all files related to FPBX.

6. Digium License Backups – If you have licenses from Digium, such as g729, it is a very good idea to back them up separately in order to facilitate easy restore. (They do get corrupted at times!). There are two options and we recommend you keep the default settings.

7. Altering the FTP information (If you are using ftp to store your backup files)

Now referring to the table at the beginning of this document you need to edit the following fields with your information IF YOU ARE USING THE FTP TRANSFER FEATURE! The ftp transfer is by default TURNED ON. Please supply the USERNAME, PASSWORD, REMOTEDIRECTORY, and SERVER. The DIRECTORY information SHOULD NOT BE CHANGED! Once you have entered the information Hold

Page 23: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 23

down the CONTROL key and tap K then X (if you are using joe) to save the file. Now you need to reopen the file to continue editing. Press the UP arrow on your keyboard once and Linux will supply your last command. Now tap the ENTER key and you will be back into the disk-backup.conf file.

Page 24: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 24

8. USB Information

From within the editor scroll down the page until you see the following:

You will need to enable using USB hard/flash drives by changing CPFLASH=”1”. It is recommended you format your USB hard/flash drive to the ext3 format and change the default from “vfat” to “ext3”. We recommend you leave USBMOUNTPOINT set to the default. You may need to change the USBDEVICENAME to what your local USB Hard/Flash drive is referred by the operating system. The steps required to ascertain this are outline in appendix one of this guide.

9. SMB Information

Page 25: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 25

From within the editor scroll down the page until you see the following:

You will need to enable using network attached SMB drives by changing CPSMB=”1”. You will need to change SMBMACHINE, SMBSHARE, SMBUSER, SMBPASS. DO NOT CHANGE THE LOCALMOUNT! NOTE SMBMACHINE MUST BE A IPADDRESS ONLY! Using a machine name will not work!

10. Pogo Plug information

Page 26: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 26

One new feature of this program is the ability to backup to an internet attached storage device referred to as a Pogo Plug. Currently the PIAF Lab backs all of it test machines to a Pogo Plug device which has a total of 8 TB of storage. The Pogo Plug is stored offsite to help assure business continuity in case of a disaster. The initial development of using this device with PIAF is all thanks to Ward © NerdUno.

You will need to enable using network attached Pogo drives by changing CPPOGO=”1”. Do not change the PMOUNT variable. Your PNAME should be your email address you use to log in to your Pogo Plug. PPAS is your password for the Pogo Plug. POGOROOT is the name your Pogo Plug assigns to the hard drives connected to the PP. This is usually the hardware name which can contain spaces. We recommend you rename the Hard drive to something that does not have spaces in the name. This can be accomplished by using the web interface to your Pogo Plug. Lastly the POGOPATH is the name of the backup folder you wish to use under the POGOROOT. It can be anything but we recommend you do not use spaces in the name. If this directory does not exist it will be created on the Pogo Plug the first time the daily-backup.cron is ran.

11. Log compression facility

Page 27: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 27

This feature allows the log file to be compressed with gzip and sent as a file attachment in an email. Normally the log file is piped to the body of the email but due to the size some email servers will reject the message.

Set GZIPPEE to equal “1” to enable this feature.

Testing the daily-backup.cron file

A critical step is to test the daily-backup.cron file. This test will take a very long time. I recommend you start it and go to lunch. In the CLI type cd /etc/cron.daily and then tap the ENTER key. Now type ./daily-backup.cron and then tap the ENTER key. Now go away for a while. If everything was configured properly the command should complete with no error messages on the screen. However your mileage may vary. I recommend you look at the log file /var/log/daily-backup.cron.log. Check on your ftp/usb/smb/Pogo sites to see if the files were copied over. There should be a file called MasterDailyBackup-XXXXXXXXXXXXX.tgz where XXXXXXXXXXXXX is a time-date stamp.

Appendix One Restoring your PBX in a Flash 1.7.5.5

Page 28: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 28

Overview

Because there are multiple ways of restoring your PBX in a Flash 1.7.5.5 system we will briefly touch on this. We really need some volunteers to help write the individual restore steps.

• Incredible PBX backups – This is well documented on Nerdvittles and the restore script needs some testing. On our test machines it seems to “work” however this method is still classed EXPERIMENTAL until some brave souls test it some more

• MySQL database dump – If you need to restore you databases this website is a good start http://crunchbang.org/archives/2007/11/18/bash-script-mysql-backup/ although this has a more in depth approach http://www.devshed.com/c/a/MySQL/Backing-up-and-restoring-your-MySQL-Database/1/

• FreePBX – Restoring from a FreePBX based backup

o Extract the FPBX archive out of the MasterDailyBackupXXXXXXX.tgz

o Copy it to /var/lib/asterisk/backups/piafbackup

o Open the FPBX gui in a browser and select the file to restore. Just follow the wizard.

o Questions?: http://www.freepbx.org/support/documentation/module-documentation/backup-and-restore

• Digium License Restore.

o Extract the DigiumLicense archive from the MasterDailyBackupXXXXXXX.tgz

o Copy it to /var/lib

o Tar –xvzf DigiumLicense*.tgz

Page 29: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 29

Appendix One Configuring and installing your USB drive

You should repartition and reformat your USB drive using Linux’s fdisk and mkfs prior to using it with PBX in a Flash 1.7.5.5. We now recommend that you reformat your USB flash drive to ext3 format which seems to be more reliable under Linux.

Setting up your USB Flash Drive

Adding a flash drive can be easily within PBX in a Flash 1.7.5.5 Insert your flash drive into a USB port and wait a few minutes. Then log in to the Command Line Interface on your PBX in a Flash using putty or a similar program and do the following.

STEP 1 Where is my drive?

Type dmesg in the CLI and tap the Enter key. You may have to look thru the output until you find something similar to below.

Notice that Centos calls USB flash drives SCSI. What you are looking for is the SCSI address that the OS assigned to it. The 9th line from the top tells us that it is device sdd. This translates to the path /dev/sdd. Please write this address down in the USB Table at the beginning of this document. Notice on the third to last line the snippet sdd: sdd1. This means that the usable partition is actually sdd1. Other names can be sdb, sdc, etc

Page 30: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 30

STEP 2 Partitioning and Formatting the USB Drive

In order to use the drive you need to repartition and format it. This will delete ALL existing information on the drive!

At the CLI type: fdisk /dev/sdd (substitute your dive letter for sdd)

Then tap the enter key and then tap the “m” key and then the Enter key. You should see a display similar to below.

Page 31: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 31

Now we need to delete the existing partition. Tap the “d” key, and then tap the Enter key. This will delete the partition.

Now create a new partition on the flash drive. Tap the “n” key and then the Enter key. It will now ask you for the Command Action tap the “p” key and then tap the Enter key. It is now asking for a Partition Number. Tap the “1” key and then tap the Enter key. Tap the Enter key twice more.

Ensure the partition type code is 83! Tap the t key and then enter 83 . You should see a screen similar to the one below and it will indicate the drive is linux.

Now write the changes to the disk. Tap the “w” key and then tap the Enter key. Eventually you will see the screen below.

Page 32: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 32

Congratulations you have successfully repartitioned you USB disk.

Now we need to format the drive using the ext3 file system. At the CLI type the following

Mkfs –t ext3 /dev/sdd1 (substitute your drive letter)

Now tap the ENTER key. You should see something similar to the screen below

You have successfully formatted you USB flash drive to use the ext3 file system.

Page 33: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 33

STEP 3 How to use the drive?

The manual way to mount and unmount your usb drive is command line based. In order to mount the drive type the following mount -t ext3 /dev/sdd1 /mnt/usbmondo and then tap the ENTER key.

Type cd /mnt/usbmondo and then tap the ENTER key. Type the command ls and then tap the ENTER key. You have successfully mounted your USB flash drive.

In order to unmount the drive type cd /root and then tap the ENTER key, Now type

umount /mnt/usbmondo

And then tap the ENTER key. The USB drive is disconnected from the mount point and no longer accessible.

For the daily-backup.cron program to work you need to ensure you unmount the USB flash drive. This helps ensure that your backup files cannot be accidentally modified.

Page 34: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 34

Appendix 2 Daily-backup.conf file

#DAILY-BACKUP.CONF #071010 #This is the external configuration file used by /etc/cron.daily/daily-backup.cron # Each line must have a # in front of it unless it is used to provide data #In other words NO BLANK LINES IN THIS FILE AT ALL!!!! #CURRENTLY EXPERIMENTAL # #*********************************************************************** #MASTER SWITCH #This indicates to disk-backup.cron that this file has been configured! #You must change it to CONFIGURED="1" for disk-backup.crion to run. CONFIGURED="0" #*********************************************************************** # # # #*********************************************************************** #CONFIGURATION OPTIONS # #Send log file via email 1=yes 0=no #Change as needed Default is 1 and will send logs to the local root email account. SENDLOG="1" # #Delete the backup files in /backup/daily after copying to remote device "1" = yes "0" = no DELBACKUPS="1" # #this is the local directory where files are located #This must exist! #DO NOT CHANGE DIRECTORY="/backup/daily" #*********************************************************************** # # #*********************************************************************** #INCREDIBLE BACKUP CONFIGURATION # # Use incredible backup methodology 0 = No 1 = Yes IBACK="0" #*********************************************************************** # # #*********************************************************************** #DATABASE CONFIGURATION # #Generate a MYSQL Dump of all databases 1=yes 0=no #Change as needed DBBACK="1" # #Default Database name for access to MySQL #Change as needed DBNAME="root" # #Default Database password for root to access MySQL #Change as needed DBPASSWORD="passw0rd" #*********************************************************************** # # #*********************************************************************** #FREEPBX CONFIGURATION # #Do freePBX backup from this file. Note if this is set to "1" you must #disable backups in the FreePBX GUI as they are not needed FPBXBACK="1" #

Page 35: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 35

#Remove fpbx from /var/lib/asterisk/backups/piafbackup 1=yes 0=no #change as needed Default is to REMOVE backup files after processing. REMFILES="1" # #These are the flags passed to the freepbx backup script #1st yes=backup Voicemail #2nd yes=backup Recordings #3rd yes=backup Configuration files #4th yes=backup CDR #5th yes=backup FOP #The default is set to yes. If you don't want to back up something replace #one of the yes's below with a no Please ensure the no is lowercase! OPTIONS="yes yes yes yes yes" #*********************************************************************** # # #*********************************************************************** #DIGIUM LICENSE CONFIGURATION #Check for and backup DIGIUM license files. 1=yes 0=no #It is recommended that you DO NOT CHANGE this setting LICBACKUP="1" # #This specifies which license files if any to back up separately #Initially this will be for digium licenses #The Digium files are located in /var/lib/digium DIGIUMLIC="/var/lib/digium" # #*********************************************************************** # # #*********************************************************************** #FTP CONFIGURATION # #Do ftp backups 1=yes 0=no Change as needed CPFTP="0" # #This should be the user name on the remote ftp machine #THIS MUST BE CHANGED USERNAME="ftpuser" # #This should be the remote ftp password.Change if needed #THIS MUST BE CHANGED PASSWORD="ftppassword" # #this should be the remote directory you wish files to go #into on the ftp server #Change if needed REMOTEDIRECTORY="/" # #this is the IP address or Fully Qualified Domain Name FQDN of the ftp server #Change to where you are sending your backups #THIS MUST BE CHANGED SERVER="ftp.server.ip" # #*********************************************************************** # # #*********************************************************************** #USB INFORMATION # #Do usb flash drive backups 1=yes 0=no Change as needed CPFLASH="0" # # #This choice allows you to specify the USB file system to mount. It is now #recommended you format your USB to ext3 format following steps in the manual #If you want to use fat32 then change the "ext3" to "vfat" below.

Page 36: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 36

USBFS="vfat" # # #USB Mount Point #This can be modified if you understand how USBMOUNTPOINT="/mnt/usbmondo" # #StickDeviceName #This may have to be modified depending on what #the OS assigns to your USB Flash Drive USBDEVICENAME="/dev/sda1" #*********************************************************************** # # #*********************************************************************** #SMB INFORMATION # #Copy files to a remote SMB mount 1=yes 0=no Change as needed CPSMB="0" # #This must be an ip address ONLY Machine names are not acceptable #THIS MUST BE CHANGED SMBMACHINE="192.168.1.2" # #This is the name of the share on the remote machine #THIS MUST BE CHANGED SMBSHARE="sharename" # #This is the local mountpoint name and path #this is created by the install-diskbackup.sh #DO NOT CHANGE! LOCALMOUNT="/mnt/smbmondo" # #This is the User name on the remote machine #for example your username on the windows machine where you are copying the files to #THIS MUST BE CHANGED SMBUSER="user" # #This is your password on the remote machine #For example your password that corresponds to the username on the remote #windows machine you are copying files to. #THIS MUST BE CHANGED SMBPASS="pass" #*********************************************************************** # # #*********************************************************************** #POGOPLUG INFORMATION *NEW* # #Copy files to pogoplug CPPOGO="0" # #This is the location the pogoplug share is mounted to already created by install-diskbackup #DO NOT CHANGE PMOUNT="/mnt/pogoplug" # #This is the username which is the pogoassigned email address #THIS MUST BE CHANGED PNAME="[email protected]" # #This is the pogoplug password #THIS MUST BE CHANGED PPASS="password" # #This is the drive name as shared on the pogoplug #THIS MUST BE CHANGED POGOROOT="16gbflash" #

Page 37: Daily Backup

Daily Backup March 2011

© Copyright 2007 – 2011 PBX in a Flash Development Corporation All Rights Reserved Page 37

#this is the destination folder on the POGOROOT drive. #it will be created if not exist only use one folder deep for the moment! #THIS MUST BE CHANGED POGOPATH="test 15" #*********************************************************************** # # #*********************************************************************** # RSYNC INFORMATION *NEW* # #Use rsync use="1" do not use="0" USYNC="0" # #At the moment the command we are using is rsync -a -v folder/* destination #If there is demand we will make the command line accessible # #*********************************************************************** # # #*********************************************************************** #GZIP LOG FILE PRIOR TO EMAIL # 0 = no gzip 1 = gzip GZIPPEE="0"