Answer the question
In order to leave comments, you need to log in
Backup to the Dropbox directory on the server without downloading the rest of the files?
I have an account on Dropbox, I have a server.
I want to backup files on the server to the backup directory on the Dropbox account in the root of the Dropbox directory.
I tried using the instructions on the Dropbox website and installed the console daemon. He earned. He gave me a link for binding, and then downloaded all the files from my account and to the server.
Hence the question:
How can I organize a backup so that the files that I use on my home computer are not downloaded to the server (they are not needed there and take up a lot of space), a separate subdirectory is synchronized - backup, for example.
The option with another account will not work for two reasons: my account is already pumped to the fullest up to 12 gigabytes and I don’t really want to pump the second one and rummage through folders with mine there, well, this is a crutch.
Well, yes. The server is on Linux, if someone hasn't guessed yet.
Answer the question
In order to leave comments, you need to log in
#!/bin/bash
#
# Dropbox Uploader Script v0.2
#
# by Andrea Fabrizi - [email protected]
# www.andreafabrizi.it/?dropbox_uploader
#
# set -x
#DROPBOX ACCOUNT
LOGIN_EMAIL="[email protected]"
LOGIN_PASSWD="password"
LOGIN_URL="https://www.dropbox.com/login"
HOME_URL="https://www.dropbox.com/home"
UPLOAD_URL="https://dl-web.dropbox.com/upload"
COOKIE_FILE="/tmp/du_cookie_$RANDOM"
RESPONSE_FILE="/tmp/du_resp_$RANDOM"
BIN_DEPS="curl sed grep"
VERSION="0.2"
#Remove temporary files
function remove_temp_files
{
rm -fr $COOKIE_FILE
rm -fr $RESPONSE_FILE
}
#Extract token from the specified form
# $1 = file path
# $2 = form action
function get_token
{
TOKEN=$(cat $1 | tr -s '\n' ' ' | sed -n -e 's/.*<form action="'$2'"[^>]*>.*<input type="hidden" name="t" value="\([a-z 0-9]*\)".*/\1/p')
echo $TOKEN
}
#CHECK DEPENDENCIES
for i in $BIN_DEPS; do
which $i > /dev/null
if [ $? -ne 0 ]; then
echo -e "Error: Required file could not be found: $i"
remove_temp_files
exit 1
fi
done
#CHECK PARAMETERS
if [ $# != 2 ]; then
echo -e " Dropbox Uploader Script v$VERSION"
echo -e " by Andrea Fabrizi - [email protected]"
echo -e "\n Usage:\t $0 [LOCAL_FILE] [REMOTE_FOLDER]\n"
echo -e " Example:\n\t $0 /etc/myfile.txt /\n"
remove_temp_files
exit 1
fi
#CHECK FILE
if [ ! -f $1 ]; then
echo -e "Error: $1: No such file or directory"
remove_temp_files
exit 1
fi
UPLOAD_FILE=$1
DEST_FOLDER=$2
echo -e " Dropbox Uploader Script v$VERSION\n"
#LOAD LOGIN PAGE
echo -ne " > Loading Login Page..."
curl -s -i -o $RESPONSE_FILE "$LOGIN_URL"
if [ $? -ne 0 ]; then
echo -e " Failed!"
remove_temp_files
exit 1
else
echo -e " OK"
fi
#GET TOKEN
TOKEN=$(get_token "$RESPONSE_FILE" "\/login")
#echo -e " > Token = $TOKEN"
if [ "$TOKEN" == "" ]; then
echo -e " Failed to get Authentication token!"
remove_temp_files
exit 1
fi
#LOGIN
echo -ne " > Login..."
curl -s -i -c $COOKIE_FILE -o $RESPONSE_FILE --data "login_email=$LOGIN_EMAIL&login_password=$LOGIN_PASSWD&t=$TOKEN" "$LOGIN_URL"
grep "location: /home" $RESPONSE_FILE > /dev/null
if [ $? -ne 0 ]; then
echo -e " Failed!"
remove_temp_files
exit 1
else
echo -e " OK"
fi
#LOAD HOME
echo -ne " > Loading Home..."
curl -s -i -b $COOKIE_FILE -o $RESPONSE_FILE "$HOME_URL"
if [ $? -ne 0 ]; then
echo -e " Failed!"
remove_temp_files
exit 1
else
echo -e " OK"
fi
#GET TOKEN
TOKEN=$(get_token "$RESPONSE_FILE" "https:\/\/dl-web.dropbox.com\/upload")
#echo -e " > Token = $TOKEN"
if [ "$TOKEN" == "" ]; then
echo -e " Failed to get Upload token!"
remove_temp_files
exit 1
fi
#UPLOAD
echo -ne " > Uploading file..."
curl -s -i -b $COOKIE_FILE -o $RESPONSE_FILE -F "plain=yes" -F "dest=$DEST_FOLDER" -F "t=$TOKEN" -F "[email protected]$UPLOAD_FILE" "$UPLOAD_URL"
grep "HTTP/1.1 302 FOUND" $RESPONSE_FILE > /dev/null
if [ $? -ne 0 ]; then
echo -e " Failed!"
remove_temp_files
exit 1
else
echo -e " OK"
fi
remove_temp_files
Great, thank you. It is a pity only it is necessary to store the login-password on the server. In the case of the DropBox daemon, a link for linking is issued and the account data is not burned ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question