Tsuasahi

自动将你的网站备份到onedrive防止数据丢失
OneDrive Free Client -- Linux下的开源客户端GitHub: https://git...
扫描右侧二维码阅读全文
24
2018/09

自动将你的网站备份到onedrive防止数据丢失

OneDrive Free Client -- Linux下的开源客户端

GitHub: https://github.com/abraunegg/onedrive

1. 依赖安装(又臭又长)

Ubuntu/Debian - x86_64

sudo apt install build-essential
sudo apt install libcurl4-openssl-dev
sudo apt install libsqlite3-dev
curl -fsS https://dlang.org/install.sh | bash -s dmd

Ubuntu - i386 / i686

sudo apt install build-essential
sudo apt install libcurl4-openssl-dev
sudo apt install libsqlite3-dev
curl -fsS https://dlang.org/install.sh | bash -s dmd

Debian - i386 / i686

sudo apt install build-essential
sudo apt install libcurl4-openssl-dev
sudo apt install libsqlite3-dev
sudo apt install git
mkdir ldc && cd ldc
wget http://ftp.us.debian.org/debian/pool/main/l/ldc/ldc_1.8.0-3_i386.deb
wget http://ftp.us.debian.org/debian/pool/main/l/ldc/libphobos2-ldc-shared-dev_1.8.0-3_i386.deb
wget http://ftp.us.debian.org/debian/pool/main/l/ldc/libphobos2-ldc-shared78_1.8.0-3_i386.deb
wget http://ftp.us.debian.org/debian/pool/main/l/llvm-toolchain-5.0/libllvm5.0_5.0.1-2~bpo9+1_i386.deb
wget http://ftp.us.debian.org/debian/pool/main/n/ncurses/libtinfo6_6.1+20180714-1_i386.deb
sudo dpkg -i ./*.deb

Fedora < Version 18 / CentOS / RHEL

sudo yum groupinstall 'Development Tools'
sudo yum install libcurl-devel
sudo yum install sqlite-devel
curl -fsS https://dlang.org/install.sh | bash -s dmd

Fedora > Version 18

sudo dnf groupinstall 'Development Tools'
sudo dnf install libcurl-devel
sudo dnf install sqlite-devel
curl -fsS https://dlang.org/install.sh | bash -s dmd

Arch Linux

sudo pacman -S curl sqlite dmd
Dependencies: Raspbian (ARM)
sudo apt-get install libcurl4-openssl-dev
sudo apt-get install libsqlite3-dev
wget https://github.com/ldc-developers/ldc/releases/download/v1.10.0/ldc2-1.10.0-linux-armhf.tar.xz
tar -xvf ldc2-1.10.0-linux-armhf.tar.xz

Gentoo

sudo emerge app-portage/layman
sudo layman -a dlang

OpenSuSE Leap 15.0

sudo zypper addrepo --check --refresh --name "D" http://download.opensuse.org/repositories/devel:/languages:/D/openSUSE_Leap_15.0/devel:languages:D.repo
sudo zypper install git libcurl-devel sqlite3-devel D:dmd D:libphobos2-0_81 D:phobos-devel D:phobos-devel-static

2.安装

上面的操作会安装DMD,它会返回给你提示如下

Run `source ~/dlang/dmd-2.082.0/activate` in your shell to use dmd-2.082.0.
This will setup PATH, LIBRARY_PATH, LD_LIBRARY_PATH, DMD, DC, and PS1.
Run `deactivate` later on to restore your environment. 

按上面的提示输入

source ~/dlang/dmd-2.082.0/activate

注意:根据您的DMD版本,请在2.082.0上面替换已安装的DMD版本。

克隆项目

常规

git clone https://github.com/abraunegg/onedrive.git
cd onedrive
make
make install

使用不同的编译器构建:
Debian - i386 / i686

git clone https://github.com/abraunegg/onedrive.git
cd onedrive
make DC=/usr/bin/ldmd2
sudo make install

ARM

git clone https://github.com/abraunegg/onedrive.git
cd onedrive
make DC=~/ldc2-1.10.0-linux-armhf/bin/ldmd2
sudo make install

授权

输入onedrive命令,会反馈给你一个链接,将他复制到浏览器并打开,登录账户并进行授权。将授权完成后的浏览器地址粘贴到ssh上

3.命令

可使用screen创建进程后台运行同步,screen使用见文章
使用screen进行多任务操作

执行同步

默认情况下,将会把全部文件下载到~/OneDrive目录下

onedrive --synchronize

选择性同步

只同步所指定目录

onedrive --synchronize --single-directory '目录名'

单向同步

只上传不同步

onedrive --synchronize --upload-only

提高日志记录级别

当运行同步时,希望看到关于客户端的进度和操作的附加信息

onedrive --synchronize --verbose

日志位于/var/log/onedrive/目录下

可选配置文件

编辑配置文件

mkdir -p ~/.config/onedrive
cp ./config ~/.config/onedrive/config
nano ~/.config/onedrive/config

sync_dir:将同步文件的目录
skip_file:同步期间将跳过与此模式匹配的任何文件或目录
skip_symlinks:同步期间将跳过符号链接的任何文件或目录
monitor_interval:监视进程处理本地和远程更改的时间间隔(秒)

将sync_dir设置为网站目录即可备份网站~


参数详解

1.sync_dir
例: sync_dir="~/FAQ"

**!!!请注意: 将~/OneDrive中的默认同步目录更改为〜/FAQ时,请谨慎操作
客户端将默认返回~/OneDrive并“认为”您的所有数据都已删除,从而删除OneDrive上的内容,或者将开始下载从OneDrive到默认位置的所有数据。!!!**

2.skip_file
例: skip_file = ".|~|Desktop|Documents/OneNote|Documents/IISExpress|Documents/SQL Server Management Studio|Documents/Visual Studio|Documents/config.xlaunch|Documents/WindowsPowerShell"

模式不区分大小写。支持*和通配符,使用|分隔多个目录。

注意:更改后skip_file,您必须执行完全同步 onedrive --resync

3.skip_symlinks
例: skip_symlinks = "true"

将此设置为"true"将在同步时跳过所有符号链接。

4.MONITOR_INTERVAL
例: monitor_interval = "300"

“同步”的等待时间。默认情况下,没有配置,monitor_interval设置为45秒。将此值设置为300则将每5分钟进行一次同步。

Last modification:May 11th, 2019 at 06:01 pm
If you think my article is useful to you, please feel free to appreciate

Leave a Comment