Rsync & Rclone

1. Syncthing(low)

https://syncthing.intbird.net

http://127.0.0.1:8384/

https://github.com/syncthing/discosrv/releases

https://github.com/syncthing/relaysrv

2: resillo(good!)

http://127.0.0.1:8888/

3: rsync (best!)

I like it a bit more

rsync: https://linux.die.net/man/1/rsync

desktop.link: add sudo ‘ sudo gsync’

gui: http://www.opbyte.it/grsync/

mount webdav: https://wiki.archlinux.org/title/Davfs2

// 挂载网盘为本地磁盘
apt-get install davfs2
mount -t davfs http://127.0.0.1 /media/pi/HDD_CLOUD/

// 本地磁盘可以比较文件的所有信息(属性,时间,大小等等)
rsync -an /media/pi/HDD_SANDISK/ /media/pi/HDD_CLOUD/

// 网盘文件只能对比大小(时间一定会被网盘服务器修改)
rsync -rhinvzPL --size-only \
/media/pi/HDD_ASUS/NetDisk/clouds/iBaidu/ \
/run/user/1000/gvfs/dav:host=127.0.0.1,port=8021,ssl=false,user=intbird/Netdisk/clouds/iBaidu/
rsync -ahnvvzPL \
--exclude={'.gradle','android'} \
--exclude={'.npm','node_modules'} \
--exclude={'.tmp','temp','temps/*'} \
--delete \
--progress \
root@intbird.net:/root/ ./root/

rsync -ahiqvzPL \
--exclude-from='rsync-exclude' \
--delete \
--progress \
root@intbird.net:/root/ ./root/
-z	传输时进行压缩提高效率
-v	显示rsync过程中详细信息。可以使用"-vvvv"获取更详细信息
-P	显示文件传输的进度信息
-a --archive	归档模式,表示递归传输并保持文件属性,等同于"-rtopgDl"
-r --recursive	以递归模式拷贝目录
-R --relative	使用相对路径
-l --links	如果文件是软链接,则拷贝软链接本身而非软链接所指向的文件
-L --copy-links	如果文件是软链接,拷贝软链接指向的文件
-W --whole-file	拷贝文件时不进行增量检测
-t --times	保持 mtime 属性
--exclude=PATTERN	指定排除不需要传输的文件模式
--include=PATTERN	指定不排除而需要传输的文件模式

|||||||||||
||||||||||╰- x: The extended attribute information changed
|||||||||╰-- a: The ACL information changed
||||||||╰--- u: The u slot is reserved for future use
|||||||╰---- g: Group is different
||||||╰----- o: Owner is different
|||||╰------ p: Permission are different
||||╰------- t: Modification time is different
|||╰-------- s: Size is different
||╰--------- c: Different checksum (for regular files), or
||              changed value (for symlinks, devices, and special files)
|╰---------- the file type:
|            f: for a file,
|            d: for a directory,
|            L: for a symlink,
|            D: for a device,
|            S: for a special file (e.g. named sockets and fifos)
╰----------- the type of update being done::
             <: file is being transferred to the remote host (sent)
             >: file is being transferred to the local host (received)
             c: local change/creation for the item, such as:
                - the creation of a directory
                - the changing of a symlink,
                - etc.
             h: the item is a hard link to another item (requires 
                --hard-links).
             .: the item is not being updated (though it might have
                attributes that are being modified)
             *: means that the rest of the itemized-output area contains
                a message (e.g. "deleting")
>f+++++++++ some/dir/new-file.txt
.f....og..x some/dir/existing-file-with-changed-owner-and-group.txt
.f........x some/dir/existing-file-with-changed-unnamed-attribute.txt
>f...p....x some/dir/existing-file-with-changed-permissions.txt
>f..t..g..x some/dir/existing-file-with-changed-time-and-group.txt
>f.s......x some/dir/existing-file-with-changed-size.txt
>f.st.....x some/dir/existing-file-with-changed-size-and-time-stamp.txt 
cd+++++++++ some/dir/new-directory/
.d....og... some/dir/existing-directory-with-changed-owner-and-group/
.d..t...... some/dir/existing-directory-with-different-time-stamp/

3.1 备注说明:

第一个字符表示文件发生了什么:

  • < 意味着文件正在传输到远程主机(发送)。
  • > 意味着文件正在传输到本地主机(接收)。
  • c 意味着该项目正在发生本地更改/创建(例如创建目录或更改符号链接等)。
  • h 意味着该项目是到另一个项目的硬链接(需要 –hard-links)。
  • . 表示该项目未更新(尽管它可能具有正在修改的属性)。
  • * 意味着分项输出区域的其余部分包含一条消息(例如“删除”)。

第二个字符表示它是什么类型的目录条目。具体来说:

  • f 对于文件
  • d 对于目录
  • L 对于符号链接
  • D 对于设备
  • S 用于特殊文件(例如套接字或 fifo)

其余列描述如下:

  • c 意味着常规文件具有不同的校验和,或者符号链接、设备或特殊文件具有更改的值。
  • s 表示常规文件的大小不同,将通过文件传输进行更新。
  • tT
    • t 表示修改时间不同,正在更新为发件人的值
    • T 表示修改时间将设置为传输时间
  • p 表示权限不同并且正在更新为发件人的值
  • o 表示所有者不同并且正在更新为发件人的值
  • g 表示该组不同并且正在更新为发件人的值
  • . 未使用

可能不存在以下列,具体取决于您的传输选项

  • a 表示ACL信息改变了
  • x 表示扩展属性信息发生了变化

4: Rclone(god!)

Docs

https://rclone.intbird.net/#/

https://rclone.org/docs/

Types

  1. localdisk: local
  2. onedrive: https://rclone.org/onedrive/

Keys

1. 本地浏览器授权

mac 客户端本地获取一份配置,将配置文件

/root/.config/rclone/rclone.conf

文件放入服务器对应目录

2. 无浏览器的服务器授权

  1. 需要添加代理 : rcloneauth.intbird.net => 127.0.0.1:53682
  2. 运行rclone config, 要求输入: https://127.0.0.1/auth?
  3. curl https://127.0.0.1/auth?, 获取onedrive最新的授权地址
  4. 替换授权地址中的 redirect_uri 为自己服务器的base64(授权地址) redirect_uri=https%3A%2F%2Frcloneauth.intbird.net%2F

5. 打开浏览器中替换后的地址,执行授权后,服务器即可完成授权

!!!重要应用

rclone sync …

https://rclone.org/commands/rclone_sync/

把整个云服务器(/root/, /etc/…)同步到onedrive上(15GB), 方便后续恢复

nohup rclone sync --dry-run  localhost:/root/ OneDrive:/OS-Backup/intbird.net/root/ >/rclone/sync.log  2>&1 & 

[1] 9671
root@intbird:~/intbird/configs/rclone# tail /rclone/sync.log
Transferred:        1.902Gi / 1.902 GiByte, 100%, 322.441 MiByte/s, ETA 0s
Transferred:        35133 / 35133, 100%
Elapsed time:         8.0s

CrossFTP

http://www.crossftp.com/

apt install openjdk-17-jdk