Categories
Emacs GNU/Linux Free Software & Open Source

3 methods on how to backup your Emacs file

Data dump by swanksalot on flickr
The emacs personalization file (dotemacs) is a very important resource for every Emacs user. Typically found at ~/.emacs, this file contains elisp code all the personalization of Emacs to accommodate each user. Its so important that it basically represents your Emacs “personality”.

To loose your .emacs file can mean loosing a lot of hours of tweaking and personalizing GNU Emacs through a bunch of collected-through-time snippets. So, being a very valuable asset, having a good method to back it up is a must have.

Here are 3 common methods people use to keep their Emacs file safe:

Simple backup

The most simple thing to do is to manually make copies of the file on a different directory, another partition on the same hard drive, an external hard drive, or a USB key. Also works well when having multiple computers and copying the same .emacs file on each of them. Using rsync to back it up periodically is a good idea, and it can be used to backup all your other elisp code for common modes (typically at ~/.emacs.d/) you use too.

A good option would be to back it up to an online storage service like Drop.io or even Amazon S3.

Version control

The standard and most common way to store your emacs customizations is by saving them on a file named .emacs placed on your home folder. But this is difficult to setup on a version control system since version control systems check things under directories. So this would mean you would be version controlling your whole home folder, which wouldn’t be a bad idea on some cases but on others would be a mess to maintain.

Fortunately there’s another way: at startup, Emacs also looks for a file called init.el on a hidden folder named .emacs.d/ in your home folder when the typical ~/.emacs file is not found. This way, you can easily set your preferred version control system to track changes on that folder. This has the advantage that any other Emacs modes or code you have can be stored and tracked too. This way, whenever you have a clean install, your Emacs setup and modes are just a checkout away from getting done.

On some setups, tracking changes on the whole ~/.emacs.d/ directory may not be a good option. So, to track changes on only your .emacs file can be achieved by moving your init.el file to a folder inside the home elisp directory and will look like this: ~/.emacs.d/dotemacs/init.el and make a symbolic link to it in ~/.emacs.d/ This way I can version control the “dotemacs” directory very easily.

Distributed version control

Many people use SVN as their preferred version control system, which backs up your data into a central location. But using a distributed version control system like Git, Mercurial or Bazaar is a better option. DVCSs let you setup multiple locations where to backup your code repository, so you don’t have a single point of failure. So you can version control your dotemacs file and back up the changes history on many places like Github, Gitorious, Launchpad or any other code hosting service, plus several other remote locations like multiple machines, a NAS or external drives with complete history of your changes.

Do you know other methods? How do you keep from loosing your dotemacs file?

Data dump image by swanksalot on Flickr

By Gabriel Saldaña

Gabriel Saldaña is a web developer, photographer and free software advocate. Connect with him on and Twitter

3 replies on “3 methods on how to backup your Emacs file”

Esto es otra pista de los respaldos que te platicaba en el blog de unison, del journal y otros archivos en Sugar, a un host remoto. Y luego de retache.

Me surgen muchas preguntas sobre cómo ha de estar estructurado el control de versiones de los archivos de Sugar y el propio Diario. Pero eso lo dejaré para otro momento, tal vez me puedas echar una mano, a lo mejor donde tengo que estudiar más para acercarme a la solución.

Va.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.