闲来无事,想着网站备份问题,当然能免费的肯定不能付费,因为用的宝塔面版,像主流的一些免费谷歌网盘,onedrive等默认空间太小无法满足要求。因此免费容量大且不限速的阿里云盘作为了第一选择。
网上太多类似教程,但很多都失效了,无法使用。这里将整个过程简单记录一下。
1、获取阿里云盘refreshToken
登陆 https://www.aliyundrive.com/sign/,阿里云盘网页版,按F12打开控制台或者谷歌浏览器右键 检查-application-Local storage-https://www.aliyundrive.com-token往下看滑动就可以看到refresh token,后面的一串字母。如下图
2、Docker安装webdav工具
宝塔后台有Docker点击,先安装docker。
安装成功后,点镜像-从仓库拉取镜像-镜像名填messense/aliyundrive-webdav-确认即可。
然后点容器-添加容器,按照图片中设置。
环境变量那里加上如下代码:
下面是用户名和密码自己设置
REFRESH_TOKEN= f9058ca5464512aa64c212a7db2 WEBDAV_AUTH_USER=admin WEBDAV_AUTH_PASSWORD=xxxx
添加成功后,可以看到已经启动了。这时可以通过IP加端口直接打开,输入帐户和密码后就可以看到云盘文件了。
3、安装Rclone进行挂载
安装rclone
curl https://rclone.org/install.sh | sudo bash
配置rclone
rclone config
然后按下面选项设置,注意选46 / WebDAV \ (webdav),可能不同版本有选项不一样,看准这个协议,选择对应数字。没有选择的就是默认ENTER。
# rclone config 2022/12/13 21:33:42 NOTICE: Config file "/home/yjitx/.config/rclone/rclone.conf" not found - using defaults No remotes found, make a new one? n) New remote s) Set configuration password q) Quit config n/s/q> n Enter name for new remote. name> aliyunwebdav Option Storage. Type of storage to configure. Choose a number from below, or type in your own value. 1 / 1Fichier \ (fichier) 2 / Akamai NetStorage \ (netstorage) 3 / Alias for an existing remote \ (alias) 4 / Amazon Drive \ (amazon cloud drive) 5 / Amazon S3 Compliant Storage Providers including AWS, Alibaba, Ceph, China Mobile, Cloudflare, ArvanCloud, Digital Ocean, Dreamhost, Huawei OBS, IBM COS, IDrive e2, IONOS Cloud, Lyve Cloud, Minio, Netease, RackCorp, Scaleway, SeaweedFS, StackPath, Storj, Tencent COS, Qiniu and Wasabi \ (s3) 6 / Backblaze B2 \ (b2) 7 / Better checksums for other remotes \ (hasher) 8 / Box \ (box) 9 / Cache a remote \ (cache) 10 / Citrix Sharefile \ (sharefile) 11 / Combine several remotes into one \ (combine) 12 / Compress a remote \ (compress) 13 / Dropbox \ (dropbox) 14 / Encrypt/Decrypt a remote \ (crypt) 15 / Enterprise File Fabric \ (filefabric) 16 / FTP \ (ftp) 17 / Google Cloud Storage (this is not Google Drive) \ (google cloud storage) 18 / Google Drive \ (drive) 19 / Google Photos \ (google photos) 20 / HTTP \ (http) 21 / Hadoop distributed file system \ (hdfs) 22 / HiDrive \ (hidrive) 23 / In memory object storage system. \ (memory) 24 / Internet Archive \ (internetarchive) 25 / Jottacloud \ (jottacloud) 26 / Koofr, Digi Storage and other Koofr-compatible storage providers \ (koofr) 27 / Local Disk \ (local) 28 / Mail.ru Cloud \ (mailru) 29 / Mega \ (mega) 30 / Microsoft Azure Blob Storage \ (azureblob) 31 / Microsoft OneDrive \ (onedrive) 32 / OpenDrive \ (opendrive) 33 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH) \ (swift) 34 / Oracle Cloud Infrastructure Object Storage \ (oracleobjectstorage) 35 / Pcloud \ (pcloud) 36 / Put.io \ (putio) 37 / QingCloud Object Storage \ (qingstor) 38 / SMB / CIFS \ (smb) 39 / SSH/SFTP \ (sftp) 40 / Sia Decentralized Cloud \ (sia) 41 / Storj Decentralized Cloud Storage \ (storj) 42 / Sugarsync \ (sugarsync) 43 / Transparently chunk/split large files \ (chunker) 44 / Union merges the contents of several upstream fs \ (union) 45 / Uptobox \ (uptobox) 46 / WebDAV \ (webdav) 47 / Yandex Disk \ (yandex) 48 / Zoho \ (zoho) 49 / premiumize.me \ (premiumizeme) 50 / seafile \ (seafile) Storage> 46 Option url. URL of http host to connect to. E.g. https://example.com. Enter a value. url> http://127.0.0.1:8080 Option vendor. Name of the WebDAV site/service/software you are using. Choose a number from below, or type in your own value. Press Enter to leave empty. 1 / Nextcloud \ (nextcloud) 2 / Owncloud \ (owncloud) 3 / Sharepoint Online, authenticated by Microsoft account \ (sharepoint) 4 / Sharepoint with NTLM authentication, usually self-hosted or on-premises \ (sharepoint-ntlm) 5 / Other site/service or software \ (other) vendor> 5 Option user. User name. In case NTLM authentication is used, the username should be in the format 'Domain\User'. Enter a value. Press Enter to leave empty. user> admin Option pass. Password. Choose an alternative below. Press Enter for the default (n). y) Yes, type in my own password g) Generate random password n) No, leave this optional password blank (default) y/g/n> y Enter the password: password: Confirm the password: password: Option bearer_token. Bearer token instead of user/pass (e.g. a Macaroon). Enter a value. Press Enter to leave empty. bearer_token> Edit advanced config? y) Yes n) No (default) y/n> Configuration complete. Options: - type: webdav - url: http://127.0.0.1:8080 - vendor: other - user: admin - pass: *** ENCRYPTED *** Keep this "aliyunwebdav" remote? y) Yes this is OK (default) e) Edit this remote d) Delete this remote y/e/d> Current remotes: Name Type ==== ==== aliyunwebdav webdav e) Edit existing remote n) New remote d) Delete remote r) Rename remote c) Copy remote s) Set configuration password q) Quit config e/n/d/r/c/s/q> q
挂载到本地
mkdir /etc/aliyunwebdav
rclone mount aliyunwebdav:/ /etc/aliyunwebdav --cache-dir /tmp --allow-other --vfs-cache-mode writes --allow-non-empty
一般会失败,出现如下问题。
这时需要安装fuse
centos安装fuse
yum install fuse
debian等安装fuse
sudo apt install fuse
安装后重新运行以下命令挂载
rclone mount aliyunwebdav:/ /etc/aliyunwebdav --cache-dir /tmp --allow-other --vfs-cache-mode writes --allow-non-empty
可以看到已经成功挂载了。
4、宝塔设置自动备份任务
首先打开面版设置-默认备份目录,设置为上面挂载的阿里云盘目录,我这里是/etc/aliyunwebdav这个目录。
然后在计划任务里设置备份计划,默认就是备份到服务器磁盘,就是你刚才设置的默认备份目录了。
5、宝塔企业版(开心版)
由于免费宝塔的Docker功能只能试用一段时间,过了后就无法使用了。这里推荐一个使用人比较多的暂时还没发现后门的宝塔企业版开心版。
Centos安装命令(默认安装是7.8.0 直接在线升级7.9.6):
yum install -y wget && wget -O install.sh http://io.bt.sy/install/install_6.0.sh && sh install.sh
试验性Centos/Ubuntu/Debian安装命令独立运行环境(py3.7) 可能存在少量兼容性问题不断优化中
curl -sSO http://io.bt.sy/install/install_panel.sh && bash install_panel.sh
Ubuntu Deepin安装命令:
wget -O install.sh http://io.bt.sy/install/install-ubuntu_6.0.sh && sudo bash install.sh
Debian安装命令:
wget -O install.sh http://io.bt.sy/install/install-ubuntu_6.0.sh && bash install.sh
Fedora安装命令:
wget -O install.sh http://io.bt.sy/install/install_6.0.sh && bash install.sh
Linux面板7.9.6 升级企业版命令1 (7.9.6 官方版/ 7.7.0 开心版可以执行这个升级到7.9.6 开心版):
curl https://io.bt.sy/install/update_panel.sh|bash
讲解:升级企业版命令1 与 升级企业版命令2 二选一都可以升级最新版!
Linux面板7.9.6 升级企业版命令2 (7.9.6 官方版/ 7.7.0 开心版可以执行这个升级到7.9.6 开心版):
curl http://io.bt.sy/install/update6.sh|bash
仅仅只是搬运作用,不对其安全性负责,自行辨别。