Introduction: Using Google Drive to Backup Any Folder & for Multiple Accounts!
Using cloud storage & backup is no doubt the best way to make your files accessible, shareable, secure, ...
I have tried several free cloud storage services & I think Google Drive 15 GB free storage is the best option available.
If you have a gmail account then you already have a 15 GB cloud storage waiting for your files!
All you have to do is to install the desktop app & any file you want to store you just drop it in the special Google Drive folder & it will be safely synced to your cloud drive.
This won't work for me!
I keep my files & separate folders & they are at their own locations on different volumes and moving all my files to the Google Drive local folder won't work for me!
Google stated that it won't sync any folder outside the Google Drive folder & several people tried some workarounds using Symbolic Links but it is not working unless you reverse the process, meaning you move your folders to the Google Drive local folder & make a SymLink to you folders in their original locations - but this is also won't work for me!
After a lot of Googling I found that gDrive is the only free tool that is able to do half of that!
Step 1: Using GDrive
- First, you need to download the version of gDrive that is compiled for your operation system from here.
- Save the downloaded EXE to a directory of your choice.
- Open a command prompt & CD to the gDrive folder.
gdrive --config .\INSTRUCTABLET-TEST list > x.txt
- Press <CTRL><C> to exit to the command prompt.
- The above will create a file in the gDrive folder named x.txt - open this with a text editor & copy the URL that is contained in that file - make sure to copy the full URL (it is quite long!)
- Open the browser & paste that link & you need to login to your Google account - (if you have multiple Google Accounts like all of us make sure that you are logged in the Google account that you want to backup to its Drive)
- You have to allow gDrive to manage the files in your Google Drive and copy the auth code.
- Now run the same command again but without the redirectio
gdrive --config .\INSTRUCTABLET-TEST list
- Paste the auth code that you got from Google and press <ENTER>
Now gDrive is ready to backup our files to the cloud Google Drive.
Step 2: Create a Google Drive Cloud Backup Folder
Google Drive is using special IDs to handle files & folders - we need to know these IDs to make our backups.
What I do is to make a back folder in the cloud Drive & use it to store all my other files and folders using gDrive mkdir command.
gdrive --config ./INSTRUCTABLES-TEST mkdir my-backup-folder
This will create the folder & print its fileID - we need to copy this fileID to be able to backup our files to this folder.
D:\Tools_\BackUp>gdrive --config ./INSTRUCTABLES-TEST mkdir my-backup-folder
Directory 0YwNzQqseEeCsY5AteFNScGJ1Wk1 created
The fileID is not perminant & you need to get this fileID every time you want to backup your files.
To get the fileID of our backup folder you need to get it using the
gdrive --config .\SCS list -q "name = 'my-backup-folder'"
Id Name Type Size Created
0YwNzQqseEeCsY5AteFNScGJ1Wk1 my-backup-folder dir 2017-01-20 09:15:51
Step 3: Backup Your Files
Now we can backup (actually we sync the files so if file is already exist it won't be uploaded again) all our files from any where in our hard drives to the cloud backup folder that we just created.
<p>gdrive --config .\INSTRUCTABLES-TEST sync upload <em>any-folder </em> <em>back-up-folder-fileID</em></p>
If you check your Google Drive just to make sure that all your files are there.
Now to reSync your files all you have to do is:
- Run the list commend to get the fileID of the backup folder
- Use that fileID to run the sync upload command.
Again, it is not a two-way sync; meaning if you uploaded a file to the Google Drive backup folder you will not be able to sync it back to the local drive unless you uploaded it using the gDrive tool - so I like to keep calling this, semi-intelligent backup.
Step 4: Handling Multiple Google Accounts
I think you already noticed the use of the --config option in all the commands that we used.
This is to force gDrive to use a specific configuration file that identify the used Google account.
If you check on the gDrive folder you'll find a folder named INSTRUCTABLES-TEST, same name we used for the --config option. In this folder you'll find a file called token_v2.json. This file has the required credentials for gDrive to access Google Drive of a specific account.
You can do the same procedure for any account you have and this is the easiest way I found to handle multiple Google Drive accounts.
If I have some free time, I may develop a GUI front-end to gDrive to make things easier.
We have a be nice policy.
Please be positive and constructive.