使用lsyncd配置數據庫備份多異地同步

lsyncd配置文件

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
35
36
37
38
39
40
41
42
settings {
    logfile = "/var/log/lsyncd.log", --日誌路徑
    status = "/var/log/lsyncd.status", --狀態文件
    pidfile = "/var/run/lsyncd.pid", --pid文件路徑
    statusInterval = 1,  --狀態文件寫入最短時間
    maxProcesses = 4,    --最大進程
    maxDelays = 1        --最大延遲
}
--多host同步
servers = {
    "192.168.1.1"
}
-- 多同步目錄,源備份用路徑和rsync節點名相同
bakpaths = {
    "mysql",
    "mongodb",
    "mssql"
}
-- 源路徑
source_path='/dbbackup/'
for _, server in ipairs(servers) do
    for _, bakpath in ipairs(bakpaths) do
    sync {
        default.rsync,
        source = source_path..bakpath,
        target = server.."::"..bakpath,
        delete "running",
        exclude = {
        }, 
        rsync = {
            binary = "/usr/local/bin/rsync", -- rsync 版本要到3以上
            archive = true,
            compress = true,
            owner = false,
            group = false,
            perms = true,
            verbose = true,
            copy_links = true
        }  
    }  
    end
end


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章