MINOR: ring: archive a previous file-backed ring on startup

In order to ensure that an instant restart of the process will not wipe
precious debugging information, and to leave time for an admin to archive
a copy of a ring, now upon startup, any previously existing file will be
renamed with the extra suffix ".bak", and any previously existing file
with suffix ".bak" will be removed.
diff --git a/src/sink.c b/src/sink.c
index ffb6cf1..806eb17 100644
--- a/src/sink.c
+++ b/src/sink.c
@@ -846,6 +846,7 @@
 		 * for ring <ring>. Existing data are delete. NULL is returned on error.
 		 */
 		const char *backing = args[1];
+		char *oldback;
 		size_t size;
 		void *area;
 		int fd;
@@ -862,6 +863,19 @@
 			goto err;
 		}
 
+		oldback = NULL;
+		memprintf(&oldback, "%s.bak", backing);
+		if (oldback) {
+			/* try to rename any possibly existing ring file to
+			 * ".bak" and delete remains of older ones. This will
+			 * ensure we don't wipe useful debug info upon restart.
+			 */
+			unlink(oldback);
+			if (rename(backing, oldback) < 0)
+				unlink(oldback);
+			ha_free(&oldback);
+		}
+
 		fd = open(backing, O_RDWR | O_CREAT, 0600);
 		if (fd < 0) {
 			ha_alert("parsing [%s:%d] : cannot open backing-file '%s' for ring '%s': %s.\n", file, linenum, backing, cfg_sink->name, strerror(errno));