您的位置:首页 > 编程语言 > ASP

Backup Raspbx system

2016-01-25 17:50 806 查看
There are two recommended options to backup your system:

1. FreePBX Backup and Restore module

This module saves all settings that have been made with the FreePBX GUI. By default, a backup is already done on the first of each month to a local file in /var/spool/asterisk/backup/Default_backup/. Just in case your system is
broken and you have not made any additional backup efforts, and assuming you still have access to these files, flash your card with a fresh image and restore your settings from there.
 The Backup and Restore module of course offers a lot more possibilities to save your settings, such as uploading them to FTP servers. Read the full documentation here: http://wiki.freepbx.org/display/F2/Backup+and+Restore
Needless to say it does not cover changes made to the system outside of FreePBX.

2. Backup the complete system to an image file

The command-line utility raspbx-backup is able to create an image file of your system, and continuously update this file with all changes. The image is similar to the .img file you’ve been initially flashing to your SD card, it
can be copied to a card in the same way. The file contains a 1:1 copy of the whole installation including all changes. As it is a single file, it can easily be stored and in case of system failure just be flashed to a new card.

The backup procedure comprises of these steps:

2.1. Create the image

The image file creation can be skipped, if you did not resize your root partition and kept the original partition size. In this case, you can just use the originally downloaded and unzipped .img file (raspbx-date.img) sized 4 GB,
and skip ahead to step 2. (On the BBB however image file creation cannot be skipped.)

The image file has to be located on an external storage, such as a USB thumb/hard drive or a mounted network share. Mount your storage to /mnt or /media/somedir, do not mount it to /media itself or anywhere else. The directories
/mnt and /media will not be backed up, and it is clear the image file itself must not be contained in the backup. As an example, mount the first external storage to /mnt:

mount /dev/sda1 /mnt

Then run the backup utility without arguments:

raspbx-backup

You will be asked for a filename with full path. Specify a file on your external storage, such as /mnt/backup.img
 Then enter the image file size in MB. In case you did not resize your root partition just keep the default. Otherwise make sure the specified size is not bigger than your card, as in this case it cannot be flashed back. In case
of doubt, specify a size about 100 MB less. A much smaller size can be used as well, if you are sure the required storage space on your card will not exceed the specified image size. For example with a 32 GB card you can work with an image file sized 8 GB,
if it is certain you are not using more than 6 GB or so.
 The image file creation will take some time, depending on the speed of your storage device. On a typical thumb drive it easily takes 20 minutes or more for 4 GB.

2.2. Continuously update the image

In case step 1 was skipped and the original image file is being used, first install required programs (this step is only required once, and not needed if step 1 was done):

apt-get install rsync

Then make sure your storage is mounted and the image file present. Run

raspbx-backup /mnt/backup.img

or specify whatever image file you are using as argument. This step is pretty fast as only files changed with regard to the previous backup are updated. If everything is fine, there will be no text output! Only in case of an error
messages will appear.
 A missing image file just produces an error message and no backup will be done, for example if the storage was not mounted due to some other error.

Assuming your storage is constantly mounted, you can just put the line above into your crontab. Run

crontab -e

then add this line at the bottom

0 4 * * * raspbx-backup /mnt/backup.img

Press Ctrl-O, Ctrl-X to save the crontab. Your system will be backed up every night at 4 a.m. See the crontab manpage for more options on how to schedule backup times:

man 5 crontab

Let’s assume you need to run a specific command for example to mount a network share where the backup file is located. In this case it is best to write a small script:

nano /root/my_backup

Your script could look like this:
#!/bin/bash
mount /dev/sda1 /mnt   #or whatever your mount command is
raspbx-backup /mnt/backup.img
umount /mnt

Then:
chmod 755 /root/my_backup
crontab -e

Add your script to the crontab instead:
0 4 * * * /root/my_backup

Mount a Windows share

Mounting a shared folder from a Windows machine on your local network is easy. First install required programs (only needed once):

apt-get install cifs-utils

Then mount the share with

mount -t cifs -o user=username,password=secret "//192.168.0.3/your share" /mnt/

Use quotes in case the share name contains spaces. This would replace the mount command in the script above.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: