首页 > 代码库 > 搭建backup服务器rsyncdaemon服务模式之二rsync客户端配置
搭建backup服务器rsyncdaemon服务模式之二rsync客户端配置
1.检查客户端是否有rsync服务:
[root@oldboy ~]# rsync --version
rsync version 3.0.6 protocol version 30
Copyright (C) 1996-2009 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
Capabilities:
64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
append, ACLs, xattrs, iconv, symtimes
rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you
are welcome to redistribute it under certain conditions. See the GNU
General Public Licence for details.
[root@oldboy ~]# rpm -qa rsync
rsync-3.0.6-12.el6.x86_64
2.客户端编辑/etc/rsync.password留下密码oldboy
[root@oldboy ~]# echo "oldboy" >/etc/rsync.password
[root@oldboy ~]# cat /etc/rsync.password
oldboy
因为有密码所以是600全新
[root@oldboy ~]# chmod 600 /etc/rsync.password
[root@oldboy ~]# ll /etc/rsync.password
-rw------- 1 root root 0 Aug 3 00:43 /etc/rsync.password
3.创建backup目录,目的:打包,推送,删除。本地临时备份目录
[root@oldboy ~]# mkdir -p /backup
[root@oldboy ~]# cd /backup
[root@oldboy backup]# touch stu{01..100}
[root@oldboy backup]# ls
stu001 stu011 stu021 stu031 stu041 stu051 stu061 stu071 stu081 stu091
stu002 stu012 stu022 stu032 stu042 stu052 stu062 stu072 stu082 stu092
stu003 stu013 stu023 stu033 stu043 stu053 stu063 stu073 stu083 stu093
stu004 stu014 stu024 stu034 stu044 stu054 stu064 stu074 stu084 stu094
stu005 stu015 stu025 stu035 stu045 stu055 stu065 stu075 stu085 stu095
stu006 stu016 stu026 stu036 stu046 stu056 stu066 stu076 stu086 stu096
stu007 stu017 stu027 stu037 stu047 stu057 stu067 stu077 stu087 stu097
stu008 stu018 stu028 stu038 stu048 stu058 stu068 stu078 stu088 stu098
stu009 stu019 stu029 stu039 stu049 stu059 stu069 stu079 stu089 stu099
stu010 stu020 stu030 stu040 stu050 stu060 stu070 stu080 stu090 stu100
4.推送到服务器端
根据: https://www.samba.org/ftp/rsync/rsync.html
SYNOPSIS
Local: rsync [OPTION...] SRC... [DEST] Access via remote shell: Pull: rsync [OPTION...] [USER@]HOST:SRC... [DEST] Push: rsync [OPTION...] SRC... [USER@]HOST:DEST Access via rsync daemon: Pull: rsync [OPTION...] [USER@]HOST::SRC... [DEST] rsync [OPTION...] rsync://[USER@]HOST[:PORT]/SRC... [DEST] Push: rsync [OPTION...] SRC... [USER@]HOST::DEST rsync [OPTION...] SRC... rsync://[USER@]HOST[:PORT]/DEST
[root@oldboy ~]# rsync -avz /backup/ rsync_backup@172.16.1.41::backup/ --password-file=/etc/rsync.password
rsync客户端
1.生成连接服务器需要的密码文件
echo "oldboy" >/etc/rsync.password
cat /etc/rsync.password
2.为密码文件配置权限
chmod 600 /etc/rsync.password
ls -l /etc/rsync.password
3.同步文件
推送:
rsync -avz /tmp/ rsync_backup@10.0.0.8::oldboy --password-file=/etc/rsync.password
rsync -avz /tmp rsync://rsync_backup@10.0.0.8/backup/ --password-file=/etc/rsync.password
拉取:
rsync -avz rsync_backup@10.0.0.8::oldboy /tmp/ --password-file=/etc/rsync.password
rsync -avz rsync://rsync_backup@10.0.0.8/backup/ /tmp --password-file=/etc/rsync.password
提示:上述backup为模块名,不是路径
本文出自 “sandshell” 博客,请务必保留此出处http://sandshell.blog.51cto.com/9055959/1953172
搭建backup服务器rsyncdaemon服务模式之二rsync客户端配置