A python script to sync your google drive contents.
- You can Download your entire google drive or any given folder
- Downloads a file only if it has been modified since last download
- Logs all actions (optional)
- Uses OAuth2 authentication and can remember authentication
- Google API Python library. To install run
pip install --upgrade google-api-python-client
oreasy_install --upgrade google-api-python-client
- Create and download your client secrets file, following the directions here. Note that the Authorised Redirect URIs might require a trailing slash, whereas the JavaScript origins must not have one.
- Copy the client secrets file to "client_secrets.json" in the same directory as the drive.py script.
- Now, if you run
python drive.py
, a browser window/tab will open for you to authenticate the script. - Once authentication is done, the script will start downloading your My Drive. Refer the next section for more options.
Following command line options are available.
--destination - Path to the folder where the files have to be downloaded to. If not specified, a folder named downloaded
is created in the current directory.
--debug - If present (accepts no value), every step will be logged to the log file.
--logfile - Path to the file to which the logs should be written to. By default, writes to drive.log
in the current directory. The file will be overwritten every time the script is run.
--drive_id ID of the folder which you want to download. By default, entire "My Drive" is downloaded.
--noauth_local_webserver Allow to fetch google oauth credentials if you run this script on a system without a browser
make build
docker run --rm -it \
-v "$HOME/client_secret_gdrive-backup.json:/client_secrets.json" \
-v "/tmp/gdrive-creds.json:/drive.dat" \
google-drive-backup \
--noauth_local_webserver
docker run --rm -it \
-v "$HOME/client_secret_gdrive-backup.json:/client_secrets.json" \
-v "/tmp/gdrive-creds.json:/drive.dat" \
-v "/tmp/gdrive:/gdrive" \
-v "/tmp/logfile.txt:/logfile.txt" \
google-drive-backup \
--debug \
--destination /gdrive/ \
--logfile /logfile.txt \
--logging_level=DEBUG