How to back up web files under Linux

  
                

When doing Linux system operations, sometimes you need to back up the web files on the Linux system, and the backup web files are generally backed up using Git software. Today, Xiaobian will introduce the next Git-based software & mdash; BUP Let's learn how to use BUP to back up web files.

BUP not simply Git, but a Git-based software. In general, I use rsync to back up my files and have been working very well so far. The only downside is that you can't restore a file to a specific point in time. So I started looking for alternatives and found BUP, a git-based software that stores data in a repository and has the option to restore data to a specific point in time.

To use BUP, you first need to initialize an empty repository and then back up all files. When the BUP completes a backup, it creates a restore point that you can restore later. It also creates an index of all files, including file attributes and checksums. When the next backup is to be made, the BUP compares the file's properties with the checksum and saves only the changed data. This saves a lot of space.

Install BUP (tested on Centos 6 & 7)

First make sure you have RPMFORGE and EPEL repositories installed

[techarena51@vps ~]$ sudo yum Groupinstall “Development Tools”[techarena51@vps ~]$ sudo yum install python python-devel[techarena51@vps ~]$ sudo yum install fuse-python pyxattr pylibacl[techarena51@vps ~]$ sudo yum install perl-Time-HiRes [techarena51@vps ~]$ git clone git://github.com/bup/bup[techarena51@vps ~]$ cd bup[techarena51@vps ~]$ make[techarena51@vps ~]$ make test[techarena51@vps ~]$ sudo make install

On CentOS 7, you may get an error when you run “make test”, but you can continue to run “make install”.

Initialize an empty repository in the first step, just like git.

[techarena51@vps ~]$ bup init

By default, bup stores the repository in “~/.bup”, but you can set the environment variable to “export BUP_DIR=/mnt/user/bup” to change the settings.

Then, create an index of all the files. This index, as I said before, stores a list of files and their properties and the git target id (sha1 hash table). (Properties include soft links, permissions and unchangeable bytes)

bup index /path/to/filebup save -n nameofbackup /path/to/file#Example[techarena51@vps ~]$ bup index /Var/www/htmlIndexing: 7973, done (4398 paths/s).bup: merging indexes (7980/7980), done.[techarena51@vps ~]$ bup save -n techarena51 /var/www/htmlReading index: 28, done.Saving: 100.00% (4/4k, 28/28 files), done.bloom: adding 1 file (7 objects).Receiving index from server: 1268/1268, done.bloom: adding 1 file (7 objects).

<BUP save” will block all the content and store them as objects. The “-n” option specifies the backup name.

You can view the backup list and the backed up files.

[techarena51@vps ~]$ bup lslocal-etc techarena51 test#Check for a list of backups available for my site[techarena51@vps ~]$ bup ls techarena512014-09-24-064416 2014-09- 24-071814 latest#Check for the files available in these backups[techarena51@vps ~]$ bup ls techarena51/2014-09-24-064416/var/www/htmlapc.php techarena51.com wp-config-sample.php wp -load.php

Backing up files on the same server is never a good choice. BUP allows you to back up web files remotely, but you must ensure that your SSH keys and BUPs are already installed on the remote server.

bup index path/to/dirbup save-r remote-vps.com -n backupname path/to/dir

Example: Backup “/var/www/html” Folder< Br>

[techarena51@vps ~]$bup index /var/www/html[techarena51@vps ~]$ bup save -r [email protected]: -n techarena51 /var/www/htmlReading index: 28, done.Saving: 100.00% (4/4k, 28/28 files), done.bloom: adding 1 file (7 objects).Receiving index from server: 1268/1268, done.bloom: adding 1 file (7 objects).

Restore Backup

Log in to the remote server and enter the following command

[techarena51@vps ~]$bup restore -C . /backup techarena51/latest#Restore an older version of the entire working dir elsewhere[techarena51@vps ~]$bup restore -C /tmp/bup-out /testrepo/2013-09-29-195827#Restore one individual file from an Old backup[techarena51@vps ~]$bup restore -C /tmp/bup-out /testrepo/2013-09-29-201328/root/testbup/binfile1.bin

The only downside is that you can't The file is restored to another server, you must manually copy the file via SCP or rsync.

View backups through an integrated web server.

bup web#specific portbup web :8181

You can use a shell script to run bup and set up a scheduled task that runs daily.

#! /bin/bashbup index /var/www/html bup save -r [email protected]: -n techarena51 /var/www/html

The above is to use BUP software to back up web files on Linux system. The process is introduced, the software still has some shortcomings, but it can already meet the basic needs, so give it a try.

Copyright © Windows knowledge All Rights Reserved