技术分享
Docker部署Urbackup备份简单实践
2020-08-24
UrBackup is an easy to setup Open Source client/server backup system, that through a combination of image and file backups accomplishes both data safety and a fast restoration time.
Urbackup一个针对文件及系统镜像做备份的开源工具,完全及增量常规的备份方式都支持,且还提供WebUI管理。
服务端通过docker快捷部署
通过数据卷,将UrBackup的备份目录和数据库目录挂载到本地目录下,在下载urbackup镜像前,要在本地创建需要映射数据卷的目录,如/media/backups和/media/database,在/media/backups中将保存实际备份数据
docker run -d --name urbackup-server-1 -v /media/backups:/backups -v /media/database:/var/urbackup -p 55413-55415:55413-55415 -p 35623:35623/udp uroni/urbackup-server
客户端安装
在web管理页面上添加client,将自动提示跳转到client安装页面,可选择不同平台的安装,支持windows,MacOS,Linux
TF=`mktemp` && wget "http://10.x.x.60:55414/x?a=download_client&lang=en&clientid=1&authkey=27Lr9gEQMU&os=linux" -O $TF && sh $TF; rm $TF--2019-08-05 17:43:51-- http://10.x.x.60:55414/x?a=download_client&lang=en&clientid=1&authkey=27Lr9gEQMU&os=linux Connecting to 10.x.x.60:55414... connected. HTTP request sent, awaiting response... 200 ok Length: 12270056 (12M) [application/octet-stream]Saving to: “/tmp/tmp.cWS7RiPshi” 100%[===========================================================================================================================================================================>] 12,270,056 33.5M/s in 0.3s 2019-08-05 17:43:52 (33.5 MB/s) - “/tmp/tmp.cWS7RiPshi” saved [12270056/12270056]Verifying archive integrity... All good. Uncompressing UrBackup Client Installer for Linux 100% Installation of UrBackup Client 2.3.4 to /usr/local ... Proceed ? [Y/n]yS Uncompressing install data... Assuming RedHat (derivative) system Detected architecture x86_64-linux-glibc Glibc not installed or too old. Falling back to ellcc build... Installed daemon configuration at /etc/sysconfig/urbackupclient... Info: Restoring from web interface is disabled per default. Enable by modifying /etc/sysconfig/urbackupclient. Installing System V init script... Starting UrBackup Client service... Starting UrBackup client: [ OK ]Successfully started client service. Installation complete. +Detected EL/RH 6. Dattobd supported -Detected no btrfs filesystem +Detected LVM volumes Please select the snapshot mechanism to be used for backups: 1) dattobd volume snapshot kernel module from https://github.com/datto/dattobd 2) LVM - Logical Volume Manager snapshots 4) Use no snapshot mechanism 4 Configured no snapshot mechanism rm: remove regular file `/tmp/tmp.cWS7RiPshi'?
在下载安装完客户端后,客户端进程将自动启动,无需再手动启动一次,通过查看socket可以看到urbackupclient
netstat -antlp | grep urbackup tcp 0 0 0.0.0.0:35621 0.0.0.0:* LISTEN 12504/urbackupclien tcp 0 0 0.0.0.0:35623 0.0.0.0:* LISTEN 12504/urbackupclien
在dnsmasq服务器上对osts文件备份,这里指定备份路径
urbackupclientctl add-backupdir -d /etc/hosts
查看当前urbackupclient的状态
urbackupclientctl status{"capability_bits": 65536,"finished_processes": [{"process_id": 1,"success": true}],"internet_connected": false,"internet_status": "no_server","last_backup_time": 1564998502,"running_processes": [],"servers": [{"internet_connection": false,"name": "10.x.x.60"}],"time_since_last_lan_connection": 23751}
查看备份目录路径
urbackupclientctl list-backupdirs PATH NAME FLAGS ---------- ----- ---------------------------------------------- /etc/hosts hosts follow_symlinks,symlinks_optional,share_hashes
在客户端上执行完全备份
urbackupclientctl start -f Waiting for server to start backup... done
进入容器,在服务端查看log,确认备份已成功
2019-08-05 09:50:46: Writing new file list... 2019-08-05 09:50:46: All metadata was present 2019-08-05 09:50:47: Transferred 6.38281 KB - Average speed: 165.992 KBit/s 2019-08-05 09:50:55: Time taken for backing up client 10.x.x.28: 10s 2019-08-05 09:50:55: Backup succeeded 2019-08-05 09:50:55: Updating statistics... 2019-08-05 09:50:55: Updating image stats... 2019-08-05 09:50:55: Updating file statistics... 2019-08-05 09:50:55: Done updating statistics. 2019-08-05 09:50:56: server_prepare_hash Thread finished (exit)2019-08-05 09:50:56: server_hash Thread finished - normal 2019-08-05 09:56:03: Looking for old Sessions... 3 sessions 2019-08-05 10:11:24: Looking for old Sessions... 3 sessions 2019-08-05 10:11:24: Session timeout: Session arichRrfTQmOBlWrofGiSHYdrnovZe
在服务器本地目录/media/backups,可以看到已经有备份数据了
ls -l /media/backups/ total 12 drwxr-x--- 5 systemd-resolve systemd-journal 4096 Aug 5 09:50 10.x.x.28 drwxr-x--- 2 systemd-resolve systemd-journal 4096 Aug 5 09:50 clients drwxr-x--- 2 systemd-resolve systemd-journal 4096 Aug 5 10:14 urbackup_tmp_files root@docker-srv60:/media/backups/10.x.x.28# ls -ltotal 12 drwxr-x--- 3 systemd-resolve systemd-journal 4096 Aug 5 09:47 190805-0947 drwxr-x--- 3 systemd-resolve systemd-journal 4096 Aug 5 09:49 190805-0948 drwxr-x--- 3 systemd-resolve systemd-journal 4096 Aug 5 09:50 190805-0950 lrwxrwxrwx 1 systemd-resolve systemd-journal 32 Aug 5 09:50 current -> /backups/10.x.x.28/190805-0950
关于客户端的文件备份的默认设置
Interval for incremental file backups:
5 hoursInterval for full file backups:
30 days
相关配置
server dir
/etc/urbackup /usr/share/urbackup /var/urbackup /backups/urbackup
client dir
/usr/local/var/urbackup /usr/local/share/urbackup /usr/local/etc/urbackup
client执行备份任务命令列表
urbackupclientctl -h USAGE: urbackupclientctl [--help] [--version] <command> [<args>]Get specific command help with urbackupclientctl <command> --help urbackupclientctl start Start an incremental/full image/file backup urbackupclientctl status Get current backup status urbackupclientctl browse Browse backups and files/folders in backups urbackupclientctl restore-start Restore files/folders from backup urbackupclientctl set-settings Set backup settings urbackupclientctl reset-keep Reset keeping files during incremental backups urbackupclientctl add-backupdir Add new directory to backup set urbackupclientctl list-backupdirs List directories that are being backed up urbackupclientctl remove-backupdir Remove directory from backup set
clinet服务启动操作命令列表
urbackupclientbackend -h USAGE: urbackupclientbackend [-r <client-confirms|server-confirms|disabled>] [-c <path>] [-j <num>] [-g <bytes>] [-t] [-w <path>] [-i] [-d] [-v <debug|info|warn|error>] [-l <path>] [--] [--version] [-h]Where: -r <client-confirms|server-confirms|disabled>, --restore <client-confirms|server-confirms|disabled> Specifies if restores are allowed and where they have to be confirmed -c <path>, --config <path> Read configuration parameters from config file -j <num>, --rotate-num-files <num> Max number of log files during rotation -g <bytes>, --rotate-filesize <bytes> Maximum size of log file before rotation -t, --no-consoletime Do not print time when logging to console -w <path>, --pidfile <path> Save pid of daemon in file -i, --internet-only Only connect to backup servers via internet -d, --daemon Daemonize process -v <debug|info|warn|error>, --loglevel <debug|info|warn|error> Specifies the log level -l <path>, --logfile <path> Specifies the log file name --, --ignore_rest Ignores the rest of the labeled arguments following this flag. --version Displays version information and exits. -h, --help Displays usage information and exits. Run UrBackup Client Backend terminating with uncaught exception of type TCLAP::ExitException Aborted

- 标签:
-
容灾备份