rsync同步服务器和笔记本文件

同步server和自己电脑的文件


Here’s a basic example of how you might do this:

两边都安装rsync:

  1. First, make sure that rsync is installed on both systems.

    On your Linux server you can install it using a package manager like apt:

    sudo apt update
    sudo apt install rsync
    

    On macOS, you can install it using Homebrew:

    brew install rsync
    

直接在电脑端运行rsync拉取服务器的文件夹:

  • 这样就会增量的把dir里面的文件同步到自己电脑的dir文件夹下:
  1. Now, assuming you have SSH access from your MacBook to your Linux server, you can use rsync to transfer a directory from the Linux server to your MacBook.

    rsync -avz -e ssh user@your_server:/path/to/dir /path/to/local/dir
    

    In this command:

    • -a stands for “archive” mode which ensures that symbolic links, devices, permissions, ownerships, modification times, ACLs, and extended attributes are preserved.
    • -v stands for “verbose” mode which provides detailed information about the amount and names of the data being transferred.
    • -z stands for “compress” which compresses data before sending it over the network.
    • -e ssh uses SSH for the data transfer.
    • user@your_server:/path/to/dir is the source directory on the Linux server.
    • /path/to/local/dir is the destination directory on your MacBook.

如果服务器ssh端口不是默认的22:

rsync -avz -e 'ssh -p 2222' user@your_server:/path/to/dir /path/to/local/dir

This rsync command will need to be run from your MacBook. If you want this to happen automatically at regular intervals, you can set up a cron job on your MacBook to run the command.

Note that rsync does not provide real-time synchronization, it simply synchronizes at the point the command is run. If you need real-time file synchronization, you might want to look into other solutions like lsyncd.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值