1. 程式人生 > >搭建backup服務器rsyncdaemon服務模式之二rsync客戶端配置

搭建backup服務器rsyncdaemon服務模式之二rsync客戶端配置

rsync

1.檢查客戶端是否有rsync服務:

[[email protected] ~]# 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.
[[email protected] ~]# rpm -qa rsync
rsync-3.0.6-12.el6.x86_64

2.客戶端編輯/etc/rsync.password留下密碼oldboy

[[email protected] ~]# echo "oldboy" >/etc/rsync.password
[[email protected] ~]# cat /etc/rsync.password
oldboy

因為有密碼所以是600全新

[[email protected] ~]# chmod 600 /etc/rsync.password
[[email protected] ~]# ll /etc/rsync.password
-rw------- 1 root root 0 Aug 3 00:43 /etc/rsync.password

3.創建backup目錄,目的:打包,推送,刪除。本地臨時備份目錄

[[email protected] ~]# mkdir -p /backup
[[email protected] ~]# cd /backup
[[email protected] backup]# touch stu{01..100}

[[email protected] 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

[[email protected] ~]# rsync -avz /backup/ [email protected]::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/ [email protected]::oldboy --password-file=/etc/rsync.password

rsync -avz /tmp rsync:[email protected]/backup/ --password-file=/etc/rsync.password

拉取:

rsync -avz [email protected]::oldboy /tmp/ --password-file=/etc/rsync.password

rsync -avz rsync:[email protected]/backup/ /tmp --password-file=/etc/rsync.password

提示:上述backup為模塊名,不是路徑

本文出自 “sandshell” 博客,請務必保留此出處http://sandshell.blog.51cto.com/9055959/1953172

搭建backup服務器rsyncdaemon服務模式之二rsync客戶端配置