无法同步文件

无法同步文件

我正在尝试在两个服务器之间同步文件:server1 和 server2 我创建了用户并授予他对 /var/www 上的 RWX 的权限,然后我添加了以下一致配置文件。

root=//var/www/html/
root=ssh://user@server2//var/www/html/environments/simreg/


log = true

ignore=Path cache
ignore=Path vendor
ignore=Path logs

auto=true
batch=true
repeat=watch
#confirmbigdel=true
confirmbigdel=false
fastcheck=true
prefer=newer
silent=false
times=true
owner=true
server = true
confirmmerge = true

backupdir = /var/www/html/environments/backup
ui = text

但是当我尝试运行一致时,它无法创建备份。调试没有用,我没有意识到我做错了什么。

user@server2:~$ unison -debug all
[startup] Preferences:
ui = text
host = 
server = true
prefsdocs = false
doc = 
version = false
silent = false
dumbtty = false
testserver = false
showprev = false
selftest = false
confirmmerge = true
retry = 0
repeat = watch
contactquietly = false
key = 
label = 
expert = false
height = 15
auto = true
maxthreads = 0
prefer = newer
force = 
sortnewfirst = false
sortbysize = false
keeptempfilesaftermerge = false
diff = diff -u CURRENT2 CURRENT1
backupdir = /var/www/html/environments/backup
maxbackups = 2
backups = false
backupsuffix = 
backupprefix = .bak.$VERSION.
backuploc = central
copymax = 1
copyquoterem = default
copythreshold = -1
copyprogrest = rsync --partial --append-verify --compress
copyprog = rsync --partial --inplace --compress
rsync = true
fastcheck = true
ignorelocks = false
dumparchives = false
ignorearchives = false
showarchive = false
rootsName = 
fat = false
allHostsAreRunningWindows = false
someHostIsRunningWindows = false
ignore = Path logs
ignore = Path vendor
ignore = Path cache
confirmbigdel = false
batch = true
root = ssh://user@server2//var/www/html/
root = //var/www/html/
killserver = false
halfduplex = false
stream = true
addversionno = false
servercmd = 
sshargs = 
rshargs = 
rshcmd = rsh
sshcmd = ssh
xferbycopying = true
sshversion = 
ignoreinodenumbers = false
links-aux = true
links = default
times = true
group = false
owner = true
numericids = false
dontchmod = false
perms = 1023
rsrc-aux = false
rsrc = default
maxerrors = 1
unicodeCS = false
unicodeEnc = false
unicode = default
someHostIsInsensitive = false
ignorecase = default
timers = false
terse = false
logfile = /var/www/html/.unison/unison.log
log = true
debugtimes = false
debug = all
addprefsto = 
Contacting server...
[remote] Shell connection: ssh (ssh, -l, dev_user, server2, -e, none, unison, -server)
user@server2's password: 
[globals] Checking path '' for expansions
Connected [//serve1//var/www/html/ -> //server2//var/www/html/]
[startup] Roots: 
        //var/www/html/
        ssh://user@server2//var/www/html/
  i.e. 
        //var/www/html/
        ssh://user@server2//var/www/html/
  i.e. (in canonical order)
       /var/www/html/
       //server1//var/www/html/

[props] Setting permission mask to 1777 (1777 and 7777)
[stasher] initBackupsLocal
[stasher] d = /
[stasher] Prefix and suffix regexps for backup filenames have been updated
[server: stasher] initBackupsLocal
[server: stasher] d = /
[server: stasher] Prefix and suffix regexps for backup filenames have been updated
[ui] Nothing changed: sleeping for 10 seconds...
[ui] Nothing changed: sleeping for 10 seconds...
[ui] Nothing changed: sleeping for 10 seconds...
[ui] Nothing changed: sleeping for 10 seconds...
[ui] Nothing changed: sleeping for 10 seconds...
[ui] Nothing changed: sleeping for 10 seconds...
[ui] Nothing changed: sleeping for 10 seconds...

上面是调试打印。但文件位于两台服务器上

答案1

您的根似乎指定错误。本地路径中的前导双斜杠//var/www/html意味着对远程服务器的引用var,我确信这不是您的意思。试试这些:

root=/var/www/html
root=ssh://user@server2/var/www/html/environments/simreg

根据您的评论,«工件部署在Server1上,然后我们需要将它们复制到Server2上。» 我认为这unison是不适合这项工作的工具。相反,请考虑使用rsync,它提供单向副本:

rsync -av --progress /var/www/html/ user@server2:/var/www/html/environments/simreg/

如果您想测试它而不实际复制任何文件,请包含--dry-run.如果您从批处理作业(cron脚本等)运行它,请删除该--progress标志。

相关内容