Las raspberry, por la experiencia que tengo ya con ellas de varios años pueden sufrir problemas con la tarjeta SD y dejarte tirado. Como me ha pasado ya varias veces, me he decidido por escribir un script en shell para salvaguardar la información. Hasta aquí, todo más o menos sencillo, el problema es... ¿donde lo almaceno?.
Gracias a mi hermano, he descubierto http://mega.nz, se trata de una nueva startup del reputado empresario Kim_Dotcom, el creador de Megaupload. Lo primero que recomiendo hacer es crearte una cuenta gratuita de Meganz (50GB gratis).
Una vez la crees, descargate el componente para utilizar via json la integración con el API de meganz, el componente se llama Megacmd
Una vez que ya tengas todo esto instalado en tu máquina, ya puedes personalizar este pequeño shell script y almacenar tus backups en la nube.
#!/bin/bash NAME=`hostname` LIMITSIZE=5485760 # 5G = 10*1024*1024k # limit size in GB (FLOOR QUOTA) MAILCMD=mail R=/home/xxxx/src LOG=$R/log/log-$(basename ${0}).log EMAILIDS="user@domain.net" MAILMESSAGE=$R/log/tmp-$(basename ${0}) if [ -d /media/4TB ] then ROOTPATH=/media/4TB/servers/$NAME # in case we've mount volume MOUNTP=/media/4TB else ROOTPATH=/opt/$NAME # in case no MOUNTP=/ fi BKDIR=$ROOTPATH/bkdir # simple text file for to list your directories for backup, normally /etc /home/user /root /var/www/html ... BKPATH=$ROOTPATH/backup FREE=$(df -k --output=avail "$MOUNTP" | tail -n1) # df -k not df -h because is more exact if [ ! -d $BKPATH ] then mkdir -p $BKPATH fi if [ ! -d $R/log ] then mkdir -p $R/log fi email_on_failure () # functions for launch email alert { sMess="$1" echo "" >$MAILMESSAGE echo "Hostname: $(hostname)" >>$MAILMESSAGE echo "Date & Time: $(date)" >>$MAILMESSAGE # Email letter formation here: echo -e "\n[ $(date +%Y%m%d_%H%M%S%Z) ] Current Status:\n\n" >>$MAILMESSAGE cat $sMess >>$MAILMESSAGE echo "" >>$MAILMESSAGE echo "*** This email generated by $(basename $0) shell script ***" >>$MAILMESSAGE echo "*** Please don't reply this email, this is just notification email ***" >>$MAILMESSAGE # sending email (need to have an email client set up or sendmail) $MAILCMD -s "Urgent MAIL Alert For $(hostname) Server" "$EMAILIDS" < $MAILMESSAGE [ -f $MAILMESSAGE ] && rm -f $MAILMESSAGE } if [ "$FREE" -lt "$LIMITSIZE" ] then echo "Writing to $LOG" echo "MAIL ERROR: Less than $((($FREE/1000))) MB free (QUOTA) on $MOUNTP!" | tee ${LOG} echo -e "\nPotential Files To Delete:" | tee -a ${LOG} find $MOUNTP -xdev -type f -size +500M -exec du -sh {} ';' | sort -rh | head -n20 | tee -a ${LOG} email_on_failure ${LOG} else echo "Currently $((($FREE-$LIMITSIZE)/1000))) MB of QUOTA available of on $MOUNTP. " fi if [ ! -f $BKDIR ] then echo "Doesn't exist bkdir file. Aborting!" exit 1 else filename=$NAME"_daily_backup_""$(date +'%Y_%m_%d')".tar.gz logfile="$R/"log/backup_log_"$(date +'%Y_%m')".log # Packages installed on Linux dpkg-query -W -f='${Installed-Size} ${Package}\n' | sort -n > $BKPATH/packages_installed.txt # Compressing my directories tar czf $BKPATH/$filename -T $BKDIR echo "dumping source code finished at $(date +'%d-%m-%Y %H:%M:%S')" >> "$logfile" # Changing permission chown root -R "$BKPATH" chown root "$logfile" chmod 644 $BKDIR chmod 600 $ROOTPATH echo "file permission changed" >> "$logfile" # removing old files and temporary files find "$BKPATH" -name "*daily_backup*" -mtime +3 -exec rm {} \; echo "old files deleted" >> "$logfile" echo "operation finished at $(date +'%d-%m-%Y %H:%M:%S')" >> "$logfile" # pushing mega.nz mega-login user@domain.net password mega-sync $BKPATH $NAME echo "pushing backup to mega.nz $(date +'%d-%m-%Y %H:%M:%S')" >> "$logfile" echo "*****************" >> "$logfile" exit 0 fi