Using Dreamhost backup account with rsync

This summer Dreamhost launched their 50Gb backup account which was great news but unfortunately they only offered FTP access. In the October newsletter they announced rsync and SCP support for the backup user using RSSH and I will now show you how to set up an automatic script to back your valuable data up. That is quite cool, so don’t hesitate to sign-up with them and try out this feature.

The first thing is configuring the account for SCP/SFTP/rsync access. Go to the Backups User section of the Users menu in the Panel and create a user. They’ll give you a name and a password and send you an email with all the information. That’s the only thing you need.

Then, you must create the folder structure to hold your backups in case you don’t want to have everything on the root folder. The easiest thing is to get a SFTP client. In my case I used WinSCP, but you can use whatever you want. I created a folder called photos to hold my digital collection.

Now, the trickiest part. If you have a modern Linux distribution or any up to date rsync compilation it’s very possible that you have version 3.0 or later that implements protocol version 30. To know the version of rsync, just write:

rsync --version

In my case, I have “rsync  version 3.0.3  protocol version 30″. In that case, if you use rsync as usual, you’ll get a nice error saying that:

insecure -e option not allowed.
This account is restricted by rssh.
Allowed commands: scp sftp rsync

After googling a little, I discovered that protocol 30 sends implicitly an -e command and the installed version in Dreamhost does not like that, because it uses protocol 29. The solution is adding ‘–protocol 29′ to the rsync options.

Then, to make the whole process automatic, you need to avoid rsync asking for a password. That can be easily done following this instructions on passwordless ssh. Note that you can’t ssh to the remote machine but if you create a new file called authorized_keys locally with the contents of id_dsa.pub and then using the SFTP client upload it to a new folder (if not exists) called .ssh (don’t forget the dot!). It will work like a charm.

Then, create a script that does the rsync thing. In my case, I have this single instruction, but you can sync as many folders as you want.

rsync -aP --delete --protocol=29 /mnt/photos/* bXXXXXXX@backup.dreamhost.com:photos

With this, I tell rsync to use archive mode (-a), which is quite interesting as it preserves timestamps and is recursive, and to store partial information (-P) in case I break the connection. Then I tell rsync to delete the destination files that are not in the source (which can be dangerous if you delete something locally and want to recover it later, so I leave this option up to you). Then to use protocol version 29 (–protocol 29) as I discussed earlier. Finally, I tell rsync which is the source folder and the destination one, indicating the username and the host.

And that’s it. If you store this command in a .sh file and put it in the crontab (with crontab -e), you can automatically back up your valuable data to the Dreamhost backup account. My crontab settings are like this:

# m h  dom mon dow   command
0 2 * * * ~/backup.sh > ~/backup.log

This will execute the backup script every day at 2 AM, and will store a .log, in case I want to check the results. Note that the first time that you execute the script it may take some time (4 days for me, 18Gb in total) depending on the amount of data to back up, so I recommend you to execute it manually before creating an automatic task.

Finally, I want to remind you that the data stored in that account is not guaranteed by any means by Dreamhost, so don’t make it your only full trusted source for backup data.

Link | Dreamhost

Note: This is my first post in English, so please forgive my errors, I tried my best. :-)

Instalando Flash 10 en Ubuntu 64 bits

Leí ayer con cierta ilusión que Adobe sacaba el Flash Player 10 simultáneamente para Mac, Linux y Windows (con algunos problemillas por lo visto) pero por lo visto siguen olvidando que somos muchos los usuarios de Linux en 64 bits.

Para Ubuntu existen unas cuantas opciones. Para empezar se puede descargar directamente de la web de Adobe y apañárselas uno mismo, pero por suerte hay gente que piensa y nos hace vagos. Por no decir que ahora mismo no me va la descarga del .deb (su enlace está mal pero se puede conseguir igualmente), que de todos modos no funciona en 64 bits.

La siguiente opción es por ejemplo, ver que en la nueva versión de Ubuntu estará el nuevo Flash, así que nos podemos bajar el .deb (abajo del todo, la versión amd64) de esa distribución (o configurar apt para que lo haga, pero es más complicado).

Acto seguido:

sudo dpkg -i flashplugin-nonfree_10.0.12.36ubuntu1_amd64.deb

Y por lo menos a mi me salta un precioso error:

*** NSPlugin Viewer  *** ERROR: libnss3.so: cannot open shared object file: No such file or directory

Por lo visto es algún tema de que faltan unas librerías en /usr/lib32, que no tengo ganas de buscar. Es tarde y quiero ver el Flash en marcha. Sigo googleando y encuentro una página con un script .sh [queleimporta.com] para hacer todo lo que siempre quise.

Es más, se puede hacer incluso en una línea:

wget http://queleimporta.com/downloads/flash10_en.sh && sudo chmod +x flash10_en.sh && sudo sh ./flash10_en.sh

Como tenía curiosidad por ver lo que hacía, lo he descargado, pero hace lo normal, quitar todo lo que pueda crear conflicto, borrar cosas que no sirven, descargar las librerías de 32 bits que faltaban y copiar los archivos descargados de Adobe. En fin, lo lógico.

Ah, cuidado al ejecutar que cierra el Firefox de forma un tanto brusca.

Finalmente, cuanto esté todo instalado y el Firefox reiniciado se pueden visitar unas bonitas demos que prepararon los de Adobe.

Enlace: La forma más fácil de instalar flash 10 en Ubuntu 64 bits [queleimporta.com]

Configurar preferences de apt-get

Llevaba unas semanas queriendo solucionar un problemilla que tenía con mi flamante Ubuntu 7.04. He llegado a ella desde “Edgy Eft” actualizando periódicamente usando las fuentes de “Feisty Fawn” a medida que iban saliendo cosas. A veces no ha sido una gran idea porque se rompe algo y hay que buscar en los foros cómo solucionarlo o arreglar a mano alguna configuración, pero en general no ha sido muy traumático.

Dicho esto, ya se está preparando la nueva release 7.10 llamada “Gutsy Gibbon“. Y me apetecía ponerme en el apt.conf las fuentes de la nueva versión. Esto es relativamente sencillo:

sudo vi /etc/apt/sources.list

Y en algún sitio de este fichero se inserta lo siguiente:

###
# Gutsy
deb http://es.archive.ubuntu.com/ubuntu/ gutsy main restricted multiverse universe
deb-src http://es.archive.ubuntu.com/ubuntu/ gutsy main restricted multiverse universe
deb http://es.archive.ubuntu.com/ubuntu/ gutsy-updates main restricted multiverse universe
deb-src http://es.archive.ubuntu.com/ubuntu/ gutsy-updates main restricted multiverse universe

Pero aquí viene el problema. Si después de eso se hace un:

apt-get update; apt-get dist-upgrade

Veremos que intenta actualizar un montón de paquetes y no me apetecía hacer tal cosa, aunque si que quiero tener los paquetes disponibles para instalar en caso de que quiera una versión más nueva que no está en ‘Feisty’ sin tener que recurrir a los backports. No sé si es porque vengo de Debian, pero a mi esto de los backports me parece una tontería.

El caso es que no quiero que apt-get instale por defecto los paquetes de Gutsy, así que la solución pasa por tocar el archivo /etc/apt/preferences de la siguiente manera:

Package: *
Pin: release o=Ubuntu,a=gutsy
Pin-Priority: 400
Package: *
Pin: release o=Ubuntu,a=gutsy-updates
Pin-Priority: 400

Esto requiere una explicación. Por defecto los paquetes instalados tienen una prioridad de 100 y los nuevos una de 500 por lo que si ponemos 400 a los de ‘Gutsy’, los nuevos que estén en cualquier otra fuente se instalarán preferentemente.

Si queremos forzar un paquete a instalar su versión de las fuentes de gutsy podemos hacer lo siguiente:

apt-get install -t gutsy vim

Y lo que hace esta instrucción es dar prioridad 900 a los paquetes de ‘gutsy’, con lo que siempre tendrán prioridad sobre el resto.

Un detalle: si tenéis el archivo /etc/apt/apt.conf puede que contenga una linea indicando la Default-Release. Si esto es así, a los paquetes de dicha release se le asigna prioridad 900 se ponga lo que se ponga en /etc/apt/preferences, por lo que es buena idea comentar la linea con // delante o borrarla.

Finalmente, para probar la configuración se puede usar el comando:

apt-cache policy
apt-cache policy vim

El primero indicará las prioridades de cada una de las fuentes del apt.conf donde podemos comprobar cuales tienen más y cuáles menos. El segundo comando listará todas las versiones disponibles del paquete indicado (‘vim’ en este caso) y con ‘***’ indicará cuál es la candidata a ser instalada.

Espero que os sirva de ayuda esta pequeña explicación de cómo usar las priorities.