4. Maintains your backuped folder structure both in Drive and after downloading it on your local machine.
git clone https://github.com/Kostas-Xafis/Google-Drive-Auto-Backup.git
cd Google-Drive-Auto-Backup
npm install
tsc -build
Note: If you have already configured google drive api in a project of yours then skip the next step.
2. Go to Google Console and create a new project.
2.2 Check external > Give an app name and an email in the 2 required inputs > Save & Continue in Scopes > In Test users add the gmail *account where your backups will be saved.
2.3 Go to Credentials > Create Credentials > OAuth client ID > Click on Desktop App in Application type dropdown > Click CREATE and then DOWNLOAD JSON.
2.4 Finally go to Marketplace from the navigation > Search for "Drive" and click the "Google Drive API" > Click enable and you are done.
3. Add the downloaded json file to the project's /json directory and remove the "installed" key, so it looks like this:
{
"client_id": "<client_id>.apps.googleusercontent.com",
"project_id": "<project_id>",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_secret": "<client_secret>",
"redirect_uris": ["urn:ietf:wg:oauth:2.0:oob", "http://localhost"]
}
4. Add a file named backupFile.json in the /json folder. Here you can add any glob pattern to exclude from your backup. You can have a general one or specify one for your backup's directory.
{
"excludePatterns": {
"*": ["**/node_modules", "etc..."],
"C:\\Users\\My_name\\personal\\projects\\etc...": ["**/.env", "**/.vscode", "**/target", "etc..."]
},
"ids": {}
}
5. If you want your backups to update automatically after a specified amount of time then you should run the setup.(bat/sh) file from the project. (Note *: .sh for unix systems is not ready yet).
#Options: HOURLY(1-23), DAILY(1-365), WEEKLY(1-52), MONTHLY(1-12)
#Setup a scheduled update every 10 hours
./setup.bat HOURLY 10
#Setup a scheduled update every 15 days
./setup.bat DAILY 15
#Setup a scheduled update every 3 weeks
./setup.bat WEEKLY 3
#Setup a scheduled update every month
./setup.bat MONTHLY 1
# Go inside the generated js folder
cd js
#Backup or update a directory
node backup <directory-to-backup> <...>
#Update for all your registered backup directories
node backupAll
#1.Remove local saved files for the backup
node delete <directory-to-remove>
#2.Both locally and in Drive
node delete <directory-to-remove> -d
node download <directory-to-download> <destination-to-install-it> <...>
#If you don't want logs to be generated
node <command> <...> -ls
#if you don't want the output to be wordy
node <command> <...> -s