liu 发布的文章

情况:

  1. home:500G

  2. root:50G

  3. root分区不够用

思路:把home分区的空间划一部分到root分区

1
2
3
4
5
6
7
8
# 设置home分区大小为200G,释放300G空间
$ lvreduce -L 200G /dev/centos/home
 
# 将空闲空间扩展到root分区
$ lvextend -l +100%FREE /dev/centos/root
 
# 使用XFS文件系统自带的命令集增加分区空间
$ xfs_growfs /dev/mapper/centos-root

实例

situation

挂载在根目录的分区 /dev/mapper/centos-root 爆满,占用100%

1
2
3
4
5
6
7
8
9
10
$ df -h
Filesystem        Size Used Avail Use% Mounted on
/dev/mapper/centos-root  50G  50G  19M 100% /
devtmpfs         32G   0  32G  0% /dev
tmpfs           32G   0  32G  0% /dev/shm
tmpfs           32G 2.5G  29G  8% /run
tmpfs           32G   0  32G  0% /sys/fs/cgroup
/dev/mapper/centos-home 476G  33M 476G  1% /home
/dev/sda1        497M 238M 259M 48% /boot
tmpfs          6.3G   0 6.3G  0% /run/user/0

analyze

挂载在根目录的分区空间太小,只有50G,而服务器 home 目录为非常用目录,挂在了近500G的空间。

思路:从 centos-home 分区划出300G空间到 centos-root 分区。

operation

1.查看各分区信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
$ lvdisplay
--- Logical volume ---
LV Path        /dev/centos/home
LV Name        home
VG Name        centos
LV UUID        1fAt1E-bQsa-1HXR-MCE2-5VZ1-xzBz-iI1SLv
LV Write Access    read/write
LV Creation host, time localhost, 2016-10-26 17:23:47 +0800
LV Status       available
# open         0
LV Size        475.70 GiB
Current LE       121778
Segments        1
Allocation       inherit
Read ahead sectors   auto
- currently set to   256
Block device      253:2
 
--- Logical volume ---
LV Path        /dev/centos/root
LV Name        root
VG Name        centos
LV UUID        lD64zY-yc3Z-SZaB-dAjK-03YM-2gM8-pfj4oo
LV Write Access    read/write
LV Creation host, time localhost, 2016-10-26 17:23:48 +0800
LV Status       available
# open         1
LV Size        50.00 GiB
Current LE       12800
Segments        1
Allocation       inherit
Read ahead sectors   auto
- currently set to   256
Block device      253:0

2.减少/home分区空间

1
2
3
4
5
6
7
8
# 释放 /dev/centos/home 分区 300G 的空间
# 命令设置 /dev/centos/home 分区 200G空间
$ lvreduce -L 200G /dev/centos/home
WARNING: Reducing active logical volume to 200.00 GiB.
 THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce centos/home? [y/n]: y
 Size of logical volume centos/home changed from 475.70 GiB (121778 extents) to 200.00 GiB (51200 extents).
 Logical volume centos/home successfully resized.

3.增加/root分区空间

1
2
3
$ lvextend -l +100%FREE /dev/centos/root
Size of logical volume centos/root changed from 50.06 GiB (12816 extents) to 325.76 GiB (83394 extents).
Logical volume centos/root successfully resized.

4.扩展XFS文件空间大小

1
2
3
4
5
6
7
8
9
10
11
$ xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=256  agcount=4, agsize=3276800 blks
     =            sectsz=512  attr=2, projid32bit=1
     =            crc=0    finobt=0 spinodes=0
data   =            bsize=4096  blocks=13107200, imaxpct=25
     =            sunit=0   swidth=0 blks
naming  =version 2       bsize=4096  ascii-ci=0 ftype=0
log   =internal        bsize=4096  blocks=6400, version=2
     =            sectsz=512  sunit=0 blks, lazy-count=1
realtime =none          extsz=4096  blocks=0, rtextents=0
data blocks changed from 13107200 to 85395456

完成

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。


BackupPC安装所需的主要的安装包下载地址:http://pan.baidu.com/s/1bnCGCY7 (BackupPC的版本为3.2.1)

(该版本的BackupPC是支持中文的,BackupPC配置好后,可以在其Web页面设置其显示语言即可)

1、添加backuppc组及用户

groupadd   backuppc

useradd   -g   backuppc   backuppc

2、安装httpd、mod_perl及BackupPC

yum   install   httpd   mod_perl

(以下安装的BackupPC和Perl*均在之前的下载包里面)

rpm   -ivh   BackupPC-3.2.1-10.el6.i686.rpm

rpm   -ivh   perl-*

3、设置页面访问权限

vim /etc/httpd/conf.d/BackupPC.conf

修改内容如下

# htpasswd   -c   /etc/BackupPC/apache.users   yourusername

order allow,deny

allow   from   all    ——》将 deny   from   all改成allow   from   all

#allow from 127.0.0.1 114.255.58.130

AuthType Basic

AuthUserFile   /etc/BackupPC/apache.users

AuthName   “BackupPC

require valid-user

</Directory>

Alias           /BackupPC/images        /usr/share/BackupPC/html/

ScriptAlias     /BackupPC               /usr/share/BackupPC/sbin/BackupPC_Admin

4、更改目录的属用户/组

chown   -R   backuppc:backuppc   /etc/BackupPC

chown   -R   backuppc:backupc   /var/lib/BackupPC

5、编辑BackupPC主配置文件

$Conf{CgiAdminUsers} = ‘backuppc’;  ——》查找到$Conf{CgiAdminUsers} 在其后面加上backuppc

6、建立用户验证文件

htpasswd -c  /etc/BackupPC/apache.users backuppc

New password: 1234

Re-type new password:1234

Adding password for user backuppc

7、启动Apache服务并设置run level 3自启动

service    httpd    start

chkconfig   –level    3    httpd   on

8、设置Backuppc用户运行指定命令

运行:visudo

修改如下:

##查到到 Defaults requiretty,并将其注释掉

##并加入以下两行信息.

Defaults !lecture

backuppc ALL=NOPASSWD:/bin/gtar,/bin/tar

9、Windows客户端配置

安装cygwin-rsyncd-3.0.9.0_installer(下载包中有)

安装完毕,修改rsyncd.conf的配置文件

#

[cDrive]    ——》与截图中位置的信息保持一致

path = /cygdrive/【要备份的盘符】/

read only = true

transfer logging = no

#auth users = backup

#secrets file = passwd

以上配置完毕后,即可开始备份了

BackupPC使用中的几个常见问题:


1、当开始完全备份时,无法正常开始备份,会提示以下错误:

Can’t call method “getStats” on an undefined value at /usr/share/BackupPC/bin/BackupPC_dump line 1160.

解决方法:

# vim   /usr/share/BackupPC/bin/BackupPC_dump

找到其1159行,内容如下:

if   ( $type   eq   “full” )    将其改成:if ( $type eq   “full”   &&   defined  ($xfer))

2、挂载其它的磁盘到BackupPC的备份目录(/var/lib/BackupPC)下时,backuppc服务无法启动,提示以下错误:

Can’t create a test hardlink between a file in /var/lib/backuppc/pc and /var/lib/backuppc/cpool

解决方法:

1)挂载后,在BackupPC的目录下新建4个文件夹:cpool、pc、pool、trash

创建方法:mkdir /var/lib/BackupPC//pc /var/lib/BackupPC//cpool /var/lib/BackupPC//pool  /var/lib/BackupPC//trash

(注意:我上面写的是没有错的,多的一个/是不能省的,不然还会出现其它错误(后期的PC数据备份中,会导致无法浏览其备份的数据信息,还有备份时所产生的日志)。)

2)将其创建的4个文件夹的权限都设置为backuppc:  chown  -R  backuppc:backuppc  cpool  pc  pool  trash


【CentOS】部署开源企业级Linux备份工具—BackupPC,布布扣,bubuko.com


Contents

 [hide

Setup

  • apt-get install apache2 backuppc libfile-rsyncp-perl

  • add to /etc/aliases

backuppc: root

If you use a dedicated disk or partition:

  • prefer reiserfs over ext3 to avoid any inode shortage problem.

  • mount it with "noatime" for better performances

  • If you've to move an existing setup, move /var/lib/backuppc to the dedicated partition but preserve hardlinks (use cp -a), then create /var/lib/backuppc symlink

To create/change http passwords:

 htpasswd /etc/backuppc/htpasswd backuppc

To create a new user:

htpasswd /etc/backuppc/htpasswd user

add to /etc/aliases

user: user@email.com

To prepare backuppc to access the hosts:

su - backuppc
ssh-keygen -t rsa -N ''

For a full restoration from scratch, see the backuppc paragraph in Harddrive

Whenever you change the config files, be sure to have the proper permissions:

chown backuppc:www-data /etc/backuppc/*
chmod go-rwx /etc/backuppc/*pl

Apache2

ln -s /etc/backuppc/apache.conf /etc/apache2/sites-enabled/backuppc

Add a host for backup

  • add it to /etc/backuppc/hosts

  • create a file such as /etc/backuppc/<host>.pl with the same name and with variables from config.pl that you want to adapt for your host

  • scp /var/lib/backuppc/.ssh/id_rsa.pub root@<host_to_backup>:

  • on the host:

    • cat id_rsa.pub >> ~/.ssh/authorized_keys

    • prepend the line in authorized_keys by sth like
      from="<my_backup_server>"
      so that only the backup host can log with this key.

    • install a ssh server if not yet done

    • install rsync

  • Try once as user backuppc to log as root on your host, first to accept the fingerprint, second to check if you are in without prompt for pwd

  • Reload hosts in backuppc: /etc/init.d/backuppc reload

Troubleshooting

Backup failed and you've only a very poor error message?

For example:

Got fatal error during xfer (Unable to read 4 bytes)

There are more complete logfiles in /var/lib/backuppc/pc/*yourmachine*/XferLOG.bad.z
But they're compressed with libz (I think) so to read the file:

$ /usr/share/backuppc/bin/BackupPC_zcat /var/lib/backuppc/pc/*yourmachine*/XferLOG.bad.z

To continue on the same example, here we got:

full backup started for directory /blabla
Running: /usr/bin/ssh -q -x -l root yourmachine /usr/bin/rsync --server --sender --numeric-ids --perms --owner --group -D --links --hard-links --times --block-size=2048 --recursive --bwlimit=1500 --ignore-times . /blabla
Xfer PIDs are now 10100
Read EOF: Connection reset by peer
Tried again: got 0 bytes
Done: 0 files, 0 bytes
Got fatal error during xfer (Unable to read 4 bytes)
Backup aborted (Unable to read 4 bytes)
Not saving this as a partial backup since it has fewer files than the prior one (got 0 and 0 files versus 0)

Ok ssh command failed. Let's try it:

# su - backuppc
$ /usr/bin/ssh -l root yourmachine ls
The authenticity of host 'yourmachine (1.2.3.4)' can't be established.
RSA key fingerprint is bl:ab:la
Are you sure you want to continue connecting (yes/no)? yes

So that's was the issue! That's what happen when you miss the last step in the paragraph about adding a host, just here above!

To invert tunnelling (if from behind a firewall)

  • On the host:

    • ssh -R 2222:localhost:22 <backup_server>
      Make it passwordless with keys

    • To make it automated: install autossh
      Add somewhere in the startup scripts:
      su <my_local_user> -c 'autossh -N -f -M 29001 -R 2222:localhost:22 <backup_server>' &

    • Or in /etc/network/interfaces
      up su <my_local_user> -c 'autossh -N -f -M 29001 -R 2222:localhost:22 <backup_server>' &
      down su <my_local_user> -c 'killall autossh'

  • On the server:

    • Host <host_to_backup_as_said_to_backuppc>

    • ~HostName <localhost or ip_pub for vservers>

    • Port 2222

    • backuppc ~/.ssh/config:

Restoring

Deleting backups

I was used to do it manually but there is a nice script here, probably handling it less wildly than what I did...

Tips

When upgrading to rsync 2.6.7 on the clients you could face some problems.
This is due to a different interpretation of the option --devices
Use -D instead for sth compatible with all rsync versions.
Change it in config.pl and other host config files: $Conf{RsyncArgs} and $Conf{RsyncRestoreArgs}
cf http://sourceforge.net/mailarchive/forum.php?thread_id=10176480&forum_id=503

Notes on new install

On the Fit PC

http://cdimage.debian.org/mirror/cdimage/unofficial/non-free/cd-including-firmware/current/i386/iso-cd/firmware-8.6.0-i386-netinst.iso

LVM

  • VG fitpc-vg

    • ext4; label HOME; use as /home; noatime,nodirtime; usage:news (more inodes)

    • swap

    • LV swap 2G => crypto; random key

    • LV root 23G => ext4; label ROOT; use as /

    • LV home 500G => crypto

Mounting encrypted home & swap failed during install -> mark them as "do not use" and see later.

  • web server ; ssh server ; standard utils

Reboot

Encrypt swap:

Create /etc/crypttab

 cswap1          /dev/disk/by-id/dm-name-fitpc--vg-swap       /dev/urandom    swap,cipher=aes-xts-plain64,size=256,hash=sha1

Add to /etc/fstab

 /dev/mapper/cswap1  none        swap    sw            0       0

Mount and format

 cryptdisks_start cswap1
 mkswap /dev/mapper/cswap1

Activate swap

 swapon -a
 free

Handle encrypted home:

Add to /etc/crypttab

 home_crypt      /dev/disk/by-id/dm-name-fitpc--vg-home       none luks,noauto

Add to /etc/fstab

 /dev/mapper/home_crypt     /home_crypt     ext4    noatime,nodiratime,noauto,errors=remount-ro 0 0

Create fs

 cryptdisks_start home_crypt
 mkfs.ext4 -i 4096 /dev/mapper/home_crypt
 mount /home_crypt

Edit /etc/hosts

127.0.1.1 fitpc.xxx.be fitpc
192.168.1.2 fitpc
...

Install stuff

 apt-get install mc screen backuppc

Move backuppc

 systemctl disable backuppc
 /etc/init.d/backuppc stop
 cp -a /var/lib/backuppc/ /home_crypt/
 rm -rf /var/lib/backuppc/
 ln -s /home_crypt/backuppc /var/lib/
 /etc/init.d/backuppc start

/root/backuppc :

 #!/bin/bash
 cryptdisks_start home_crypt
 mount /home_crypt
 /etc/init.d/backuppc start

Fix /etc/backuppc/apache.conf:

Options ExecCGI FollowSymlinks
=>
Options +ExecCGI +FollowSymlinks

then

service apache restart

Update web passwd and create key:

htpasswd /etc/backuppc/htpasswd backuppc
su - backuppc
ssh-keygen -t ed25519 -N 
exit

Sensors:

apt-get install lm-sensors sensord
sensors-detect # use default, no need for optional scans
# -> coretemp
echo -e "chip \"acpitz-virtual-0\"\n        ignore temp1\n        ignore temp" > /etc/sensors.d/fitpc-sensors.conf

Read sensors:

sensors
acpitz-virtual-0
Adapter: Virtual device

coretemp-isa-0000
Adapter: ISA adapter
Core 0:       +51.0°C  (crit = +90.0°C)

Edit /etc/default/sensord

ALARM_INTERVAL=1m
LOG_INTERVAL=30m
SYSLOG_FACILITY=daemon
RRD_FILE=/var/log/sensord.rrd
RRD_INTERVAL=5m
RRD_LOADAVG=yes
service sensord restart

Emails: Change /etc/exim4/update-exim4.conf.conf

dc_eximconfig_configtype='smarthost'
dc_smarthost='smtp.belgacom.net'
update-exim4.conf
service exim4 restart

Change /etc/email-addresses (= From:)

root: some_valid_email
backuppc: some_valid_email

Add to /etc/aliases (= To: for backuppc users)

myuser: some_valid_email

Edit /etc/mailname

xxx.be

Fix localhost backup (auth errors):

apt-get install sudo
echo "backuppc ALL = NOPASSWD: /bin/tar" > /etc/sudoers.d/backuppc

Then edit /etc/backuppc/localhost.pl

$Conf{TarClientCmd} = '/usr/bin/env LC_ALL=C $tarPath -c -v -f - -C $shareName'
=>
$Conf{TarClientCmd} = '/usr/bin/env LC_ALL=C /usr/bin/sudo $tarPath -c -v -f - -C $shareName'

Add a machine:

  • Add machine in /etc/hosts

192.168.x.x mymachine
  • From machine: (assuming fitpc2 is in its /etc/hosts, warning some devices don't seem to support the "from=")

sudo apt-get install openssh-server rsync
(echo -n "from=\"<IP_of_fitpc2>\" ";ssh root@fitpc2 cat /var/lib/backuppc/.ssh/id_ed25519.pub) |sudo tee -a /root/.ssh/authorized_keys
  • Test from the server twice (once to accept fingerprint, once to check):

su -c "ssh root@mercure_eth" - backuppc
  • Add it to /etc/backuppc/hosts

mymachine 0       myuser   backuppc
  • Create a file /etc/backuppc/<host>.pl with the same name as in /etc/hosts and /etc/backuppc/hosts and with variables from config.pl that you want to adapt for your host

  • Reload

service backuppc reload


1、创建软链接

  具体用法是:ln  -s   [源文件]   [软链接文件]。

复制代码

[root@localhost folder]# pwd/tmp/folder
[root@localhost folder]# ll
total 4drwxr-x--- 2 root root 4096 Apr 30 16:46 files
[root@localhost folder]# ln -s /tmp/folder/files /tmp/folder/files_ln
[root@localhost folder]# ll
total 4lrwxrwxrwx 1 root root   17 Apr 30 16:49 files_ln -> /tmp/folder/files
drwxr-x--- 2 root root 4096 Apr 30 16:46 files

复制代码

  -s 是代号(symbolic)的意思。这里有两点要注意:

    第一,ln命令会保持每一处链接文件的同步性,也就是说,不论你改动了哪一处,其它的文件都会发生相同的变化;

    第二,ln的链接又软链接 和硬链接两种,软链接就是ln -s ** **,它只会在你选定的位置上生成一个文件的镜像,不会占用磁盘空间,硬链接ln ** **,没有参数-s, 它会在你选定的位置上生成一个和源文件大小相同的文件。

  无论是软链接还是硬链接,文件都保持同步变化,都不会将原本的档案复制一份,只会占用非常少量的磁碟空间。。

  【硬连接】

  硬连接指通过索引节点来进行连接。在Linux的文件系统中,保存在磁盘分区中的文件不管是什么类型都给它分配一个编号,称为索引节点号(Inode Index)。在Linux中,多个文件名指向同一索引节点是存在的。一般这种连接就是硬连接。硬连接的作用是允许一个文件拥有多个有效路径名,这样用户就可以建立硬连接到重要文件,以防止“误删”的功能。其原因如上所述,因为对应该目录的索引节点有一个以上的连接。只删除一个连接并不影响索引节点本身和其它的连接,只有当最后一个连接被删除后,文件的数据块及目录的连接才会被释放。也就是说,文件真正删除的条件是与之相关的所有硬连接文件均被删除。

  【软连接】  

  另外一种连接称之为符号连接(Symbolic Link),也叫软连接。软链接文件有类似于Windows的快捷方式。它实际上是一个特殊的文件。在符号连接中,文件实际上是一个文本文件,其中包含的有另一文件的位置信息。

  【两种链接的区别】

  硬链接文件有两个限制:
    1)、不允许给目录创建硬链接。
    2)、只有在同一文件系统中的文件之间才能创建链接,而且只有超级用户才有建立硬链接权限。
  对硬链接文件进行读写和删除操作时候,结果和软链接相同。但如果我们删除硬链接文件的源文件,硬链接文件仍然存在,而且保留了原有的内容。其原因是因为对应的文件的索引节点有一个以上的连接。只删除一个连接并不影响索引节点本身和其它的连接,只有当最后一个连接被删除后,文件的数据块及目录的连接才会被释放。文件才会被真正删除。
  注:保存在磁盘分区中的文件不管是什么类型都给它分配一个编号,称为索引节点号(Inode Index即I节点)。
  软链接没有硬链接以上的两个限制,因而现在更为广泛使用,它具有更大的灵活性,甚至可以跨越不同机器、不同网络对文件进行链接。但是软链接的缺点在于:因为链接文件包含有原文件的路径信息,所以当原文件从一个目录下移到其他目录中,再访问链接文件,系统就找不到了,而硬链接就没有这个缺陷,你想怎么移就怎么移;还有它要系统分配额外的空间用于建立新的索引节点和保存原文件的路径。

  【参数说明】

  -f : 链结时先将与 dist 同档名的档案删除
  -d : 允许系统管理者硬链结自己的目录
  -i : 在删除与 dist 同档名的档案时先进行询问
  -n : 在进行软连结时,将 dist 视为一般的档案
  -s : 进行软链结(symbolic link)
  -v : 在连结之前显示其档名
  -b : 将在链结时会被覆写或删除的档案进行备份
  -S SUFFIX : 将备份的档案都加上 SUFFIX 的字尾
  -V METHOD : 指定备份的方式
  --help : 显示辅助说明
  --version : 显示版本

2、修改软链接

   ln –snf  [新的源文件或目录]   [软链接文件]

复制代码

[root@localhost folder]# ll
total 4lrwxrwxrwx 1 root root   17 Apr 30 16:49 files_ln -> /tmp/folder/filesdrwxr-x--- 2 root root 4096 Apr 30 16:46 files
[root@localhost folder]# ln -snf /tmp/folder    /tmp/folder/files_ln[root@localhost folder]# ll
total 4drwxr-x--- 2 root root 4096 Apr 30 16:46 files
lrwxrwxrwx 1 root root   11 Apr 30 16:59 files_ln -> /tmp/folder

复制代码

3、删除软链接

  rm –rf   ./软链接名称

  rm -rf ./软链接名称/ (这样就会把软链接以及软链接指向下的内容删除)

复制代码

[root@localhost folder]# ll
total 4lrwxrwxrwx 1 root root   17 Apr 30 16:49 files_ln -> /tmp/folder/files
drwxr-x--- 2 root root 4096 Apr 30 16:46 files
[root@localhost folder]# rm -rf ./files_ln
[root@localhost folder]# ll
total 4drwxr-x--- 2 root root 4096 Apr 30 16:46 files
[root@localhost folder]# ll
total 4lrwxrwxrwx 1 root root   17 Apr 30 16:49 files_ln -> /tmp/folder/files
drwxr-x--- 2 root root 4096 Apr 30 16:46 files
[root@localhost folder]# rm -rf ./files_ln/[root@localhost folder]# ll
total 0

复制代码


This is a complete guide to install BackupPC on your CentOS 7 server.

#Install BackupPC and prerequsities

yum upgrade -y
yum install epel-release
yum install backuppc nfs-utils nfs-utils-lib bzip2
systemctl restart backuppc.service

#Set permissions

cd /usr/share/BackupPC/
chown backuppc:apache sbin/*

cd /usr/share/BackupPC/sbin
chmod u+s BackupPC_Admin

usermod -s /bin/bash backuppc

#Set firewall rule for HTTP port.

firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload

#Edit BackupPC config

vi /etc/BackupPC/config.pl

Edit

$Conf{CgiAdminUserGroup} = '';
 $Conf{CgiAdminUsers} = '';

TO

$Conf{CgiAdminUserGroup} = '';
 $Conf{CgiAdminUsers} = 'backuppc';

THEN

Edit

$Conf{PingPath} = '';

TO

$Conf{PingPath} = '/bin/ping';

#Edit your apache configuration

vi /etc/httpd/conf.d/BackupPC.conf
<Directory /usr/share/BackupPC/>
 # BackupPC requires valid authentication in order for the web interface to
 # function properly. One can view the web interface without authentication
 # though all functionality is disabled.
 #
 # htpasswd -c /etc/BackupPC/apache.users yourusername
 #
AuthType Basic
 AuthUserFile /etc/BackupPC/apache.users
 AuthName "BackupPC"
<IfModule mod_authz_core.c>
 # Apache 2.4
 <RequireAll>
 Require valid-user
 <RequireAny>
 Require local
 # --> In order to access only this specific IP
 Require ip 192.168.16
 # --> Uncomment for access everywhere
 # Require all granted
 </RequireAny>
 </RequireAll>
 </IfModule>
 <IfModule !mod_authz_core.c>
 AllowOverride All
 Order allow,deny
 Deny from all
 </IfModule>
</Directory>
Alias /BackupPC/images /usr/share/BackupPC/html/
 ScriptAlias /BackupPC /usr/share/BackupPC/sbin/BackupPC_Admin
 ScriptAlias /backuppc /usr/share/BackupPC/sbin/BackupPC_Admin

#Create username and password for BackupPC GUI

htpasswd -c /etc/BackupPC/apache.users backuppc

New password:
Re-type new password:
Adding password for user backuppc

#Restart your services

systemctl restart backuppc.service
systemctl restart httpd.service

#Then add your ssh key to your remote server.

su - backuppc
ssh-keygen -t rsa

Generating public/private rsa key pair.
Enter file in which to save the key (/var/lib/BackupPC/.ssh/id_rsa):
Created directory ‘/var/lib/BackupPC/.ssh’.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /var/lib/BackupPC/.ssh/id_rsa.
Your public key has been saved in /var/lib/BackupPC/.ssh/id_rsa.pub.

ssh-copy-id root@your-remote-ip

#Test it.

ssh root@your-remote-ip

#Then go

http://your-ip/BackupPC

#Enter your username and password that you created before #htpasswd -c /etc/BackupPC/apache.users backuppc

#Go “Edit Hosts”

#Click Add

#Then write an hostname or IP of your remote server

#Then click SAVE

#Refresh your page and select your host.

!!! DO NOT FORGET INSTALL RSYNC TO YOUR REMOTE SERVER !!!

#Click “Edit Config” for your selected host

#Select Xfer

#Add “*” value for “BackupFilesOnly” Box

#Write down your path name that you want to create backup in RsyncShareName Box

#Then Click Save.!

#Click Start FULL BACKUP

You are ready to go!

Windows SMB Backup

You can also take backup of your Windows clients using BackupPC

The basic steps are

  • Create a backuppc user in your domain/client with backup operator privileges

  • Create a share on client server and give read and list folder permissions to backuppc user

  • Create inbound firewall rule for BackupPC server

  • Test your configuration by typing from BackupPC Server

    • smbclient -U “Domain\backuppc” //CLIENTIP/ShareName

    • You will see smb prompt, try to list the files by typing “dir”

  • Add the client to backuppc and edit the credentials:

    • change Xfer method to SMB

    • enter username as DOMAIN\user

    • enter password

    • change share name from C$ to Share Name given