How to move one database in influx to another server? - influxdb

I want to move one database from one server to another
I followed this guide: https://docs.influxdata.com/influxdb/v0.12/administration/config/
But when I restored metadata I wiped out all my usernames and passwords with new db.
Do I need to restore metadata at all and is there are way to restore it without wiping out existing databases?

Metadata should not be imported when importing one database to an existing server.

Related

use pre-populated realm databse

I want to create an offline iOS application using Realm. Users just need to read the database, they don't need to update or create entries.
I can create my pre-populated database using Realm Studio and I need to use that database file in my final app so users can access the database with the same data. For example, jobs.realm file with same data should be available to the users when they first launch the app.
I've been searching for a solution but couldn't find anything I can understand.
Follow the documentation for bundling a realm file: https://realm.io/docs/swift/latest/#bundling-a-realm

CoreData:Migrate data from bundled db

Our app is having a coredata store which is based on a single coredata model. There are read-only data as well as read-write data.
The read-only data are pre-loaded and bundled along with the app, so that on a fresh install, this database is copied to the application sandbox and from there on the data base will be updated via webservice (ie only the changed data will get updated from webservice so that less data is transferred).
Now we have situation where we need to add more attributes to the read-only entities.
Light weight migration will help in upgrading the schema easily, but the problem is about the new data, since we are adding new attributes to all the read-only entities, all the data records are changed and a webservice sync might take a lot of time to download and update data. To avoid this we are bundling the updated data along with the app ( this will solve the issue for a fresh install). But for the users which are upgrading the app is there a standard mechanism to copy the read-only entities from the bundled db and update those to the existing database in the sandbox so that they will get the updated read-only data and also their read-write data remains intact.
UPDATE
Here is the scenario,
I have X.sqlite bundled with the proj (which has new schema), if X.sqlite is not there in doc dir I then copy it and from there everything works OK. Now in the App update scenario, X.sqilte will be already present in doc dir and won’t be copied and the migration assistant will migrate the schema. So now we have X.sqlite with the new schema in doc dir but old data (without new attributes). Now what I want to know is if there is a way to merge the data from bundled X.sqlite with the one which is there in the doc dir. I want to know if there is a process for merging.
To be more precise
Below are the entities
*Store - ReadOnly
*Products - ReadOnly
*ProductGroups - ReadOnly
*ShopList - User based
All are in the same model and in the same store.
Now Store/ Products / ProductGroups have extra attributes.
Lightweight migrator will migrate the schema of X.Sqlite so that the DB will have the new attribute columns.
Now what I am concerned is the next step,
Lets take Store as an example. Store has two new attributes latitude and logitude. Now the question how to copy the data? the steps
Copying the bundled DB to doc dir with diff name?
Create a new persistance co-ordinator?
Read the bundled data and get the objects?
then iterate through the existing db?
If I have understood your question: you want to update read-only data during app update--while leaving read-write data that user has changed intact.
There are several ways to achieve this:
Have two separate databases. One database can have the read-write
data and another with read-only data. They can relate to each other
using fetched properties. During update, replace or update the
read-only database--while leaving the read-write one intact.
Update the database using a background thread. The update code will
have it's own ManagedObjectContext--but sharing the same
PersistentStore. Synch the main ManagedObjectContext from the
background thread using some protocol.
The second option of updating from a background thread might work well if you choose to update from your web service.
If I haven't understood your issue, please clarify.
Ok So finally after a lot of research I achieved my goal, below are the trails and solutions that i did
Sol 1
Have the read-only and read-write data in separate databases, so that I can safely delete the readonly db if there is any master data update and I can safeguard user's data, but considering the timelines and constraints that I have, it wont be possible for me. Posting here so that it might help others.
Sol 2
I thought rather trying to merge the new data from bundled DB to the existing DB, I thought of merging the user data from existing db to the new db. Below are the steps done.
--> Created a new datacontext.
--> Created a new persistent co-ordinator
--> Renamed the bundled db with _v2 and copied it to the Doc directory, now we have 2 DB in the doc dir
I took some app Importing large data sets
--> Now using the ManagedObject clone category, I copied all the user info data from the existing db to the new db _v2. Found the category here NSManagedObject+Clone
--> Worked fine, now I got my _v2 database with new readonly data and the user data from the old database.
--> Now I need to give control back to the default datacontext
--> I tried to change the PSC of the old context to the new PSC but system didnt allow me to do that.
--> I then tried to change the persistence store of the old context to the new store but I got error saying that database already exists. (migratePersistentStore:toURL:options:withType:error:)
--> I ran out of ideas here.
Sol 3
I then discussed my problems with some of my other colleagues and they suggested to provide the new data in a different format and that striked. As I already mentioned, my app has logic to download new data as JSON and merge it to core data, why can I provide a JSON file with the new data, along with my app?
I collected the new response from thew webservice and created a JSON (not big just 1.5MB) and attached with app bundle, and for users that update the app, instead of core data merging I will read the JSON data locally and do the initial merging to the core data DB, there by the data base will have the new readonly data and also user data intact. After the initial merge, everything will be taken care by online sync.

Core Data Transform iOS

I am developing a sample application with core data with a entity which has two attribute-ID and name.For ID I have set the data type as transformable .After a value for ID is stored in database,Can I pull the transformed ID from the DB and get back the ID?(Not Through the code, by opening the DB in SQLite manager and pulling out from the ID column).Is there a way to check what is stored in DB manually without executing code?
Thanks in advance
You can copy the DB from the device to your machine. I use iExplorer to do this. The best way to view/edit the DB from there is Base, but Firefox has a FREE plugin called SQLite Manager.

Retrieving database into an iphone app

My iPhone app is required to work offline, so I need te retrieve the db from the server into the devise.
The database contains about 10 tables with a few dozen lines each.
What is the recommended way for doing so?
Is it the sqlite3?if so, how can I build the sqlite tables from the DB?
Thanks,
Asaf
You have multiple options:
download a sqlite database file from webserver, store it in your app's document or temp folder
create the database and tables dynamically by code, set up an XML or JSON interface on your webserver, download the data from web and insert to the new database
Take a look here for a beginning with SQLite on iOS.
And yes, it is sqlite3 on iOS.
I ship my apps with the tables built, with some data, then have the app call a web service that takes "last updated" as a parameter, and returns all additions/deletions since then (as JSON)...the app then parses that, and inserts/updates/deletes as needed

How do I restore three items from a backup made using Heroku PG Backups?

I've got a Rails app running on Heroku and installed the free pgbackups addon.
There's three records I'd like to restore from the backup.
According to Heroku docs when you do a restore, it restores the whole database.
How do I restore just these three records?
Create a new database, load the pgbackup into it, and then cherry pick what you want out of it.
As far as I know Heroku is using what's referred to as the "-Fc" format for everything, which is described in the pg_dump section of the manual as the custom format. That can't be read by anything but pg_restore, so you're limited to what it knows how to do. You can get pg_restore to only process a single table, which can speed things up if your database is big and you only care about a few records in one table. But there's no way to only get a few records restored out of there; you'll have to restore the entire table they're in and then dump them back out.

Resources