Index: trunk/src/org/openstreetmap/josm/data/Preferences.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/Preferences.java	(revision 2037)
+++ trunk/src/org/openstreetmap/josm/data/Preferences.java	(revision 2038)
@@ -13,4 +13,5 @@
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
+import java.nio.channels.FileChannel;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -44,5 +45,5 @@
 
     /**
-     * Internal storage for the preferenced directory.
+     * Internal storage for the preference directory.
      * Do not access this variable directly!
      * @see #getPreferencesDirFile()
@@ -291,6 +292,11 @@
         try {
             setSystemProperties();
+            String prefFile = getPreferencesDir() + "preferences";
+
+            // Backup old preferences
+            copyFile(new File(prefFile), new File(prefFile + "_backup"));
+
             final PrintWriter out = new PrintWriter(new OutputStreamWriter(
-                    new FileOutputStream(getPreferencesDir() + "preferences"), "utf-8"), false);
+                    new FileOutputStream(prefFile + "_tmp"), "utf-8"), false);
             for (final Entry<String, String> e : properties.entrySet()) {
                 String s = defaults.get(e.getKey());
@@ -301,4 +307,9 @@
             }
             out.close();
+
+            File tmpFile = new File(prefFile + "_tmp");
+            copyFile(tmpFile, new File(prefFile));
+            tmpFile.delete();
+
         } catch (final IOException e) {
             e.printStackTrace();
@@ -307,4 +318,32 @@
         }
     }
+
+    /**
+     * Simple file copy function that will overwrite the target file
+     * Taken from http://www.rgagnon.com/javadetails/java-0064.html (CC-NC-BY-SA)
+     * @param in
+     * @param out
+     * @throws IOException
+     */
+    public static void copyFile(File in, File out) throws IOException  {
+        FileChannel inChannel = new FileInputStream(in).getChannel();
+        FileChannel outChannel = new FileOutputStream(out).getChannel();
+        try {
+            inChannel.transferTo(0, inChannel.size(),
+                    outChannel);
+        }
+        catch (IOException e) {
+            throw e;
+        }
+        finally {
+            if (inChannel != null) {
+                inChannel.close();
+            }
+            if (outChannel != null) {
+                outChannel.close();
+            }
+        }
+    }
+
 
     public void load() throws IOException {
