Skip to content

Instantly share code, notes, and snippets.

@changux
Created August 15, 2018 16:10
Show Gist options
  • Save changux/4238b0fa33d02f88fc6558120ba2285f to your computer and use it in GitHub Desktop.
Save changux/4238b0fa33d02f88fc6558120ba2285f to your computer and use it in GitHub Desktop.
Script to execute a gmail backup and sync to another account
#!/bin/bash
# Add cron to execute every day
# 0 12 * * * cd ~/my/backup/script && ./backup-gmail-account.sh >> /var/log/script_output.log 2>&1
# sudo pip install gmvault
#
BACKUPMAIL=$HOME/gmvault-db
#
# Initial setup
if [ ! -d "$BACKUPMAIL" ]; then
/usr/local/bin/gmvault sync main-account@gmail.com # or gapps mail account
else
# Incremental and sync
/usr/local/bin/gmvault sync -t quick main-account@gmail.com
/usr/local/bin/gmvault restore --type quick backupaccount@gmail.com
fi
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment