Try use jStorage, it supports most browsers, except the ones without localStorage (like deprecated Safari3)
It got lots of functions, but we can try achieve what you want with those:
set(key, value)
$.jStorage.set(key, value)
Saves a value to local storage. key needs to be string otherwise an exception is thrown. value can be any JSONeable value, including objects and arrays or a XML node.
Currently XML nodes can't be nested inside other objects: $.jStorage.set("xml", xml_node) is OK but $.jStorage.set("xml", {xml: xml_node}) is not.
get(key[, default])
value = $.jStorage.get(key)
value = $.jStorage.get(key, "default value")
get retrieves the value if key exists, or default if it doesn't. key needs to be string otherwise an exception is thrown. default can be any value.
flush()
$.jStorage.flush()
Clears the cache.
index()
$.jStorage.index()
Returns all the keys currently in use as an array.
var index = $.jStorage.index();
console.log(index); // ["key1","key2","key3"]
With that in mind, considering you already have a DB set up, you can use var index = $.jStorage.index();
and with the array, create a jQuery .each() loop that gets each key of the array and call the get() $.jStorage.get(key)
and add to a big string, that in the end can be parsed as .csv, or even XML or json (you choose).
With these data in hands, you can $.jStorage.flush()
to clear.
Then, if you want to import the data for a new DB, all you need to do is a .each() that reads the string/file you've saved and start setting the kay/value par with $.jStorage.set(key, value)
.
If you don't have a DB already, just populate a new one with $.jStorage.set(key, value)
.
:)