Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

利用脚本实现unraid共享目录文件与网盘文件相互加密备份,定时同步

Featured Replies

用了一段时间了,挺稳定的,所以放出来共享下。

我是专门注册了一个免费的阿里云盘用来备份unraid上数据。

需要用到docker应用和插件,都是免费的。如果你不用alist之类的网盘工具,请略过。

你们如果有更好更简便不花钱的实现方式请留言。

 

思路:

1、alist之类的工具实现网盘http、webdav服务。

 

2、利用davfs2 filesystem这个插件实现 网盘webdav挂载到unraid本地文件夹中

具体看这里:

 

 

3、利用 User Scripts 插件执行脚本,做定时备份。

 

以上三个应用是我unraid必装的,所以不用这几个插件的朋友可略过。

 

以下是脚本,请根据自己情况修改:

#!/bin/bash
# 利用davfs2 filesystem插件挂载备份目录,请先安装davfs2
# http://192.168.1.31:5244/dav/webdav_backup alist网盘目录,指向某个阿里云目录。请自定义
# /mnt/user/webdav/aliyun_backup是网盘挂载到本地unraid路径,请自定义

echo "http://192.168.1.31:5244/dav/webdav_backup admin 123456" | sudo tee -a /etc/davfs2/secrets && sudo mount -t davfs http://192.168.1.31:5244/dav/webdav_backup /mnt/user/webdav/aliyun_backup

# 检查挂载命令的退出状态
if [ $? -ne 0 ]; then
    echo "挂载失败。请查看错误消息。"
else
    echo "挂载成功,正在继续执行加密备份命令..."
source_dir="/mnt/user/zdisk1/backup/mi10/SwiftBackup_8c10b180d4813f28/log" # 请自定义unraid需要备份的目录
destination_dir="/mnt/user/webdav/aliyun_backup/log" #网盘挂载到本地后的目录
encryption_password="135246"  # 这里是备份文件时候加密密码,请替换为你的加密密码,文件上传到网盘中是加密的

# 清理源目录中超过3天的文件
# 请根据自己需求是否删除此命令
find "$source_dir" -type f -mtime +3 -exec rm {} \;
echo "清理源目录中超过3天的文件完成"

# 获取当前时间作为备份文件名
backup_filename="backup_$(date +%Y%m%d%H%M%S).tar.gz"
backup_path="$source_dir/$backup_filename"

# 打包压缩源目录
tar -czvf "$backup_path" -C "$source_dir" .

# 使用 openssl 进行加密
openssl enc -aes-256-cbc -salt -pbkdf2 -in "$backup_path" -out "$backup_path.enc" -k "$encryption_password"

echo "备份加密文件完成"

# 复制加密的备份文件到目标目录
cp "$backup_path.enc" "$destination_dir"
echo "备份加密文件已复制到阿里云目录"

# 删除源目录中的临时备份文件
rm "$backup_path.enc"
rm "$backup_path"
echo "删除源目录中的临时备份文件完成"

# 删除目标目录中超过5天的备份文件
# 请根据自己需求是否保留此命令
find "$destination_dir" -name "backup_*.tar.gz.enc" -type f -mtime +5 -exec rm {} \;
echo "保留阿里云目录中超过3天的备份文件完成"
fi

# 取消挂载备份目录
sleep 10s
umount /mnt/user/webdav/aliyun_backup
echo "阿里云目录取消挂载成功,备份完成"

 

Edited by suosuosi

谢谢分享

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.