Skip to content

Instantly share code, notes, and snippets.

@fisadev
Last active August 29, 2015 14:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fisadev/aa4dada3a7845a278890 to your computer and use it in GitHub Desktop.
Save fisadev/aa4dada3a7845a278890 to your computer and use it in GitHub Desktop.
Backup automático de gmail
[general]
accounts = GMail
maxsyncaccounts = 3
[Account GMail]
localrepository = Local
remoterepository = Remote
autorefresh = 5
quick = 5
[Repository Local]
type = Maildir
localfolders = /home/pepita/backup_gmail
[Repository Remote]
type = IMAP
remotehost = imap.gmail.com
remoteuser = pepitalapistolera@gmail.com
remotepass = AGUANTE_LA_PISTOLA_PASSWORD
ssl = yes
maxconnections = 1
sslcacertfile = /etc/ssl/certs/ca-certificates.crt
realdelete = no
#!/bin/bash
BACKUP_DATE=$(date)
echo "----------------------------------------------"
echo "Start backup" $BACKUP_DATE
# si no tenes nice, ionice, nocache, podes sacarlos y la cosa puede correr igual,
# pero va a hacerte lenta la maquina cuando corra
run-one nice ionice nocache offlineimap -o
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
#notify-send "Error or backup already running" -i gtk-cancel
echo "Error or backup already running"
else
#notify-send "Backup done" -i gtk-ok
echo "Backup done"
fi
echo "End backup" $BACKUP_DATE
  1. Instalar offlineimap y otras dependencias:
sudo apt-get install offlineimap nocache run-one
  1. Crear una config de offlineimap:

Tiene que ser un archivo llamado .offlineimaprc en tu home, con el contenido que muestra el gist. Reemplaza lo que corresponda con tu path, usuario y password.

  1. Crear el script de backup:

Ponelo donde quieras, con el contenido que se muestra en el gist (backup_gmail.sh), y hacé que sea ejecutable (chmod +x backup_gmail.sh)

  1. (opcional) Si querés que se corra solo a cada hora, agregá esto a tu cron:
0 * * * * /path/al/backup_gmail.sh >> /path/donde/quieras/guardar/logs/backup_gmail.log 2>&1

Si no, corré el script a mano cuando quieras backupear y listo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment