首先在Linux上安装Dropbox,不同操作系统执行以下命令:
32-bit:
cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86" | tar xzf -
64-bit:
cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86_64" | tar xzf -
安装好之后发现家目录下并没有新增文件?
其实是有新增的,被隐藏在.dropbox-dist。
~/.dropbox-dist/dropboxd
执行上面这个程序用于关联账户,第一次执行会给出如下链接。
在浏览器中打开此链接即可自动关联你的Dropbox账户。
This computer isn't linked to any Dropbox account...
Please visit https://www.dropbox.com/cli_link_nonce?nonce=xxxx to link this device.
关联好之后Dropbox文件夹会出现在你的家目录中:
ll | grep Dropbox
drwx------ 3 xxx xxx 4096 Jun 23 10:44 Dropbox
接下来下载一个python 脚本Python script控制Dropbox,替代~/.dropbox-dist/dropboxd
~ python dropbox.py
Dropbox command-line interface
commands:
Note: use dropbox help <command> to view usage for a specific command.
status get current status of the dropboxd
throttle set bandwidth limits for Dropbox
help provide help
stop stop dropboxd
running return whether dropbox is running
start start dropboxd
filestatus get current sync status of one or more files
ls list directory contents with current sync status
autostart automatically start dropbox at login
exclude ignores/excludes a directory from syncing
lansync enables or disables LAN sync
sharelink get a shared link for a file in your dropbox
proxy set proxy settings for Dropbox
Tips: 即便之前在本地没有生成Dropbox目录,执行如下脚本成功后,仍可以生成Dropbox目录。
python dropbox.py start
python dropbox.py status
Up to date
Dropbox 程序正在运行,且已同步。此时把文件移动到Dropbox目录中即可自动上传,so easy.
写一个每天自动执行一次的 job 把所有数据 dump 出来,压缩一下,按日期命名,最后上传,一个简单的数据备份就做好了。
网友评论