Start by creating a service account for your Google Cloud project.
Create a local_settings.py
file in the same folder as settings.py
,
and define a DRIVE_BACKUP_FOLDER_ID
variable with the ID of the Google Drive folder you want to upload to as value.
(Alternatively, this ID can be provided using the -i
option described below.)
Run the following command to upload <filename>
to the previously specified folder:
python backup_to_drive.py <filename>
-i, --folder-id <Google Drive folder ID>
- defaults toDRIVE_BACKUP_FOLDER_ID
-p, --no-prefix
- prevents prefixing a timestamped string to the uploaded file's name
Requires having set the python3
command to a version of Python >= 3.7.
It's possible to use the provided bash script, which can be installed using the following command:
sudo ln -s <full path to this repo locally>/backup-to-drive.sh /bin/backup-to-drive
After that, it can be used in the following manner (with same options as above):
backup-to-drive <filename>