Dropbox 同步-使用 Linux Command Line

  Linux, Subversion

步驟如下:
1.參照Dropbox官方教程安裝linux版本的Dropbox. 參考https://www.dropbox.com/install?os=lnx按照command line方式安裝即可。

2.安裝好之後配置賬戶
執行~/.dropbox-dist/dropboxd,按提示操作

3.軟連接需要備份的數據到~/Dropbox目錄,dropboxd服務啟動之後就會自動同步了。

4.配置dropboxd開機啟動
這裡提供centos腳本,其他系統如ubuntu沒有測試應該不用改。創建/etc/init.d/dropboxd文件,內容如下:

# chkconfig: 345 85 15
# description: Startup script for dropbox daemon
#
# processname: dropboxd
# pidfile: /var/run/dropbox.pid
#
# Source function library.
. /etc/rc.d/init.d/functions
DROPBOX_USERS="user1 user2"
prog=dropboxd
lockfile=${LOCKFILE-/var/lock/subsys/dropbox}
RETVAL=0
start() {
        echo -n $"Starting $prog"
         for dbuser in $DROPBOX_USERS; do
            daemon --user $dbuser /bin/sh -c "/home/$dbuser/.dropbox-dist/dropboxd&"
        done
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch ${lockfile}
         return $RETVAL
}
stop() {
        echo -n $"Stopping $prog"
    for dbuser in $DROPBOX_USERS; do
        killproc /home/$dbuser/.dropbox-dist/dropboxd
    done
        RETVAL=$?
         echo
        [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
   restart)
        stop
        start
        ;;
  *)
        echo $"Usage: $prog {start|stop|restart}"
        RETVAL=3
esac
exit $RETVAL

請自行把user1 user2改成你自己的賬戶名,腳本參考http://blog.justin.kelly.org.au/running-dropbox-on-centos-in-a-headlessvps-se/

5.設置開機啟動

sudo chmod +x /etc/init.d/dropboxd
sudo /etc/init.d/dropboxd start
chkconfig dropboxd on

6.Dropbox CLI命令行設置
下載https://www.dropbox.com/download?dl=packages/dropbox.py,放在/usr/bin/dropbox.py,賦予執行權限,即可使用。

wget https://www.dropbox.com/download?dl=packages/dropbox.py
sudo mv dropbox.py /usr/bin/dropbox.py
sudo chmod +x /usr/bin/dropbox.py
sudo ln /usr/bin/dropbox.py /usr/bin/dbox

接著就可以使用dbox命令使用dropbox了。

[root@web ~]# dbox help
Dropbox command-line interface
commands:
Note: use dropbox help  to view usage for a specific command.
 status       get current status of the dropboxd
 help         provide help
 puburl       get public url of a file in your dropbox
 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