Instruktaż/Tutorial Jak wykonać kopie zdalnej maszyny Linuxowej za pomocą BackupPC?

Silas Mariusz

rm -rf /
Help us, GOD!
5 Kwiecień 2008
10 210
31
2 313
153
39
Nowy Sącz
forum.qnap.net.pl
QNAP
TS-x77
Ethernet
1 GbE
Introduction
BackupPC is a backup solution that can be configured to back up remote Linux and Windows systems. It can use a variety of different protocols and has a flexible scheduler to coordinate full and incremental backups.

In this guide, we will install BackupPC on an Ubuntu 12.04 VPS and use it to back up a second Ubuntu 12.04 VPS.


Install BackupPC
Download: BackupPC [x86]
..
..
..
..


Configure SSH Access to Client Computers
There are a few different ways that servers and clients can communicate to authenticate and transfer data. In this guide, we will be using the rsync protocol over SSH.

To make this work, we'll need to create an SSH key pair for our system BackupPC user (called "backuppc", as mentioned above), and then transfer the key to the client machines.

First, log into the BackupPC user with the following command:
Bash:
sudo su - backuppc

You will probably be presented with only a minimal prompt, represented by the dollar sign ($).

Generate an SSH key pair by typing:
Bash:
ssh-keygen

You will be asked a number of questions. Just type "Enter" through all of the prompts to accept the default values.

Transferring the SSH Public Key
You now have a private and public key on your backup server. You need to transfer the public key to the root user on each client machine you wish to access.

You can do that by typing:
Bash:
ssh-copy-id root@client_ip_address

Type "yes" to accept the new server's identity, and then enter the root password of the remote machine. The key should then be transfered.

Check that your key was transfered correctly by typing:
Bash:
ssh root@client_ip_address

You should be able to log in without having to type a password.

Get back to the BackupPC server by typing:
Bash:
exit

Back out of the "backuppc" account by typing "exit" again:
Bash:
exit


Access the Web Interface
The rest of the guide will be configured through BackupPC's web interface.

Open a browser and navigate to: http://backuppc_server_ip_address/backuppc

You will be prompted for a username and password. The username is "backuppc" and the password is what you set with the htpasswd command earlier.

aassets.digitalocean.com_articles_backuppc_main_page.png


Set Up Client Configuration
On the left-hand side, click on the "Edit Hosts" link.

aassets.digitalocean.com_articles_backuppc_edit_hosts.png


Click the "Delete" button next to "localhost", since we are only backing up remote machines.

Next, click "Add". Fill in the client machine's IP address. For user, add "backuppc", since we have given that user SSH access to the host.

aassets.digitalocean.com_articles_backuppc_remote_host.png


Click "Save" at the top of the page.

Configure Transfer Settings
Click on the "Xfer" tab on the top of the page. Under "XferMethod", select "rsync". Under "RsyncShareName", select the path you would like to back up.

You can leave it at "/" to back up the entire computer. You can also click "Add" to add additional areas to back up if you choose not to target the entire computer.

aassets.digitalocean.com_articles_backuppc_rsync_settings.png


If you are backing up the entire computer, you'll need to add an "excludes" rule.

In the "BackupFilesExclude" segment, type "*" to match all shares. Then insert the values "/proc" and "/sys" to exclude these directories from back up.

aassets.digitalocean.com_articles_backuppc_rsync_excludes.png


Note: Failure to set up the appropriate exclude rule for the "proc" and "sys" folders can result in a backup that does not finish.

Again, click "Save" at the top of the page to enable your configuration changes.

Configure Backup Schedule
The default backup schedule is:
  • Full backup
    • Every 7 days
    • Keep only newest copy
  • Incremental backup
    • Every day
    • Keep the six most recent backups
If you would like to change the interval, click on the "Schedule" tab on the top bar.

aassets.digitalocean.com_articles_backuppc_backup_schedule.png


Note: You will notice that full backups have a value of "6.97" in "FullPeriod", and likewise, incremental backups have a value of "0.97" in the "IncrPeriod" field. These are values corresponding to 7 and 1 day respectively, since it accounts for the time to complete the backup as well.

You can modify the number of backups that the system maintains. You can also specify times when no backup should be performed by setting up "blackouts" where no backup can begin.

In this guide, we will stick with the default values.

Remember to click "Save" if you make any changes.


Run a Manual Backup
To run your first full backup manually, select you client from the "Hosts" drop-down menu in the upper-left corner.

You will be taken to a client summary page. Click "Start Full Backup" under the "User Actions" section.

aassets.digitalocean.com_articles_backuppc_full_backup_button.png


You will confirm the action on the next page.

aassets.digitalocean.com_articles_backuppc_backup_confirmation.png


Your backup should complete shortly, depending on the size of the droplets.

The files will be stored at:
/share/mountpoint//var/lib/backuppc/pc/ip_address_of_client/#_of_backup

This value will be printed in the "Backup Summary" portion of the Host summary.

aassets.digitalocean.com_articles_backuppc_backup_summary.png


If you click on the "Browse backups" button in the upper-left corner, you can get an overview of the filesystem, as backed up by BackupPC.

aassets.digitalocean.com_articles_backuppc_browse_backups.png


Using this tool, you can browse the filesystem and select the files you'd like to restore.


Conclusion
BackupPC is a powerful, user-friendly way to automatically backup files from several servers to a central location. Backups are essential for any kind of production environment. Just as important is making sure that file restoration operations function correctly.

There are many backup tools available for Linux and Unix-like operating systems. Choose the solution that fits your needs the best. BackupPC is a great tool that should work well in many developers' environments.

By Justin Ellingwood


Źródło: How To Use BackupPC to Create a Backup Server on an Ubuntu 12.04 VPS | DigitalOcean