# README: Google Drive Backup Automation
This repository contains scripts designed to automate the backup process of certain files, upload them to Google Drive, and handle post-upload cleanup. Here are the prerequisites, setup process, usage, customization options, and details about setting up a cron job for these scripts.
## Prerequisites
- A Unix-based operating system (e.g., Linux or macOS).
- Terminal or command-line interface access.
- A Google Drive account.
- Google Client ID and Client Secret for `gdrive` setup.
## Setup
### 1. Clone the Repository and Set Permissions
```bash
git clone [repository_url]
cd [repository_directory]
```
Provide execution permissions to the scripts:
```bash
chmod +x go.sh remote.sh remove_file.sh
```
### 2. Installing and Configuring `gdrive`
Fetch the `gdrive` binary, unpack, and move it to an accessible location:
```bash
curl -LJO https://github.com/glotlabs/gdrive/releases/download/3.9.0/gdrive_linux-x64.tar.gz
tar -xvf gdrive_linux-x64.tar.gz
sudo mv gdrive /usr/local/bin/
```
#### On a Local Machine:
1. Add a Google Account to `gdrive`:
```bash
gdrive account add
```
2. Enter the Google Client ID and Client Secret when prompted. Navigate to the provided authorization URL to grant `gdrive` access to your Google Drive.
3. You'll be redirected to `http://localhost:8085` to complete the setup.
#### On a Remote Server:
For remote servers, authorize on a local machine first, then transfer the credentials to the remote server:
1. On your local machine:
```bash
gdrive account add
gdrive account export <ACCOUNT_NAME>
```
Transfer the exported archive to the remote server.
2. On the remote server:
```bash
gdrive account import <ARCHIVE_PATH>
```
### 3. Further Configuration and Cleanup (if required)
After setting up `gdrive`, you can remove any unnecessary files or configurations:
```bash
rm gdrive_linux-x64.tar.gz
rm [path_to_your_gdrive_export_file]
```
## Usage
Run the backup process manually:
```bash
./go.sh
```
This sequence will:
- Archive specific files into a ZIP using `remote.sh`.
- Upload the ZIP to a predefined Google Drive folder.
- Delete the ZIP from the local system using `remove_file.sh`.
## Customization
- Replace `[FOLDER_ID]` in `go.sh` with your Google Drive folder's actual ID.
- If you want to alter which files or directories are included in the ZIP, modify the `remote.sh` script.
## Setting Up a Cron Job
To automate the backup process, set up a cron job that triggers the script at desired intervals.
1. Open the crontab editor:
```bash
crontab -e
```
2. Add the following line to schedule the script to run every day at 12 AM:
```bash
0 0 * * * /home/user/[repository_name]/go.sh
```
3. Save and exit the editor.
4. To verify your cron jobs:
```bash
crontab -l
```
This will list all cron jobs set up for the user. Ensure your new job is listed.
---
Thank you for using the Google Drive Backup Automation suite. For challenges or recommendations, please open an issue or submit a pull request.