Keeping a backup of your Google Account is essential, as losing access to it could be disastrous.
Google provides Google Takeout, a tool that allows you to generate a complete copy of your data. However, manually going through the process of creating an archive, downloading it, and storing it on a hard drive can be tedious—so I automated it!
- Google Takeout Automation: Google Takeout is configured to automatically export data to Google Drive every two months.
- Local Backup: A Raspberry Pi with an external hard drive runs a Python script that periodically checks for new Takeout exports in Google Drive.
- Download & Cleanup: If a new export is found, the script downloads it to the local hard drive, removes the old backup, and cleans up the Takeout folder in Google Drive.
Ensure the following dependencies are installed on your system:
- Python 3 (
python3) - pip for Python 3 (
python3-pip) - rclone (for interacting with Google Drive)
If Python 3 and pip are not already installed, run the following command:
sudo apt update && sudo apt install -y python3 python3-pipFollow the official rclone installation guide to install it on your system.
Refer to the rclone documentation to set up Google Drive as a remote.
It is recommended to name the remote default.
Since the backup files are large, it's best to use an external hard drive. Follow these steps to properly mount it.
Run the following command to find the drive’s UUID:
sudo blkidLook for your drive (e.g., /dev/sda), which will have an output similar to:
/dev/sda: UUID="YOUR_UUID_HERE" TYPE="ntfs"
Copy the UUID value (inside the quotes).
sudo mkdir /mnt/usbEdit the /etc/fstab file:
sudo nano /etc/fstabAdd this line at the end (replace YOUR_UUID_HERE with the copied UUID):
UUID=YOUR_UUID_HERE /mnt/usb ntfs-3g defaults,auto,users,permissions 0 0
Save and exit (CTRL + X, then Y, then Enter).
Manually mount all drives to check if the configuration is correct:
sudo mount -aVerify by listing the contents of the mounted drive:
ls /mnt/usbRestart the Raspberry Pi:
sudo rebootAfter rebooting, ensure the drive is still mounted:
ls /mnt/usbIf the files are visible, the setup is complete.
- Clone the repository:
git clone https://gitlab.com/niehaus1301/gtakeout-local.git- Navigate to the directory:
cd gtakeout-local- Create a virtual environment at the project root (
/venv):
python3 -m venv venv- Activate the virtual environment:
source venv/bin/activate- Install required dependencies:
pip install -r requirements.txt- Run the script manually:
python3 main.py <rclone remote name (default)> <path to local backup directory>Example:
python3 main.py default /mnt/usbIf you want the script to run automatically in the background, you can set it up as a systemd service.
At the root level of the repository, there is a gtakeout-auto.service file. Copy it to the appropriate systemd directory:
sudo cp gtakeout-auto.service /etc/systemd/system/Reload systemd to recognize the new service:
sudo systemctl daemon-reloadEnable the service to start automatically on boot:
sudo systemctl enable gtakeout-auto.serviceStart the service manually for the first time:
sudo systemctl start gtakeout-auto.serviceTo confirm that the service is running, use:
sudo systemctl status gtakeout-auto.serviceIf everything is working correctly, you should see output indicating that the service is active and running.
- Go to Google Takeout.
- Select all the data you want to back up.
- Under "Choose file type, frequency and destination", select "Add to Drive".
- Set the frequency to "Export every 2 months for 1 year".
- Adjust "File type & size" as needed.
- Click "Create export"—you're done!
Now, your backups will be automatically downloaded and stored securely! 🚀
