If I was to accidentally run a UserModel.remove({}, cb) and delete all of my user documents, how would I retrieve those documents? Would the process be same on a local DB on my computer VS a DB hosted on a remote server such as mLab?
No they can not be retrieved back once deleted. The only way to recover the data is to create a dump of that collections before deleting it or if you have a replica of that server. You can restore it from that.
Related
I backed up a neo4j database using
bin/neo4j-admin dump --database=neo4j --to=c:/
Then I load a database from an archive created with the dump command as follow
bin/neo4j-admin load --from=/var/lib/neo4j/data/c: --database=db
From Neo4j Enterprise Browser I execute
SHOW DATABASES
but I don't see the db previously loaded. How could I show it ?
If you are replacing your existing database with name "db" then use the --force option:
bin/neo4j-admin load --from=/var/lib/neo4j/data/c: --database=dbase --force
If you are restoring into a new database, then after the load, you need to create the database CREATE DATABASE dbase
Note that I changed the name of your database from db to something else since database names in Neo4j must be at least 3 characters long.
I have two sets of databases for my different testing environments (internal qa and uat). I'm trying to bring qa up to date by restoring it from the latest uat backups. I encountered an issue with the qa DBs getting stuck in "restoring" mode and ended up deleting them, so I'm trying to create a brand new database now by restoring from the UAT backup and changing the name, but it keep failing.
Restore database
Source: device > latestUATbackup.bak
Destination: database > change name from UAT.Web to Dev.Web
Files > check off Relocate all files to folder
Options: Close existing connections to destination database
"Restore of database Dev.Web failed. Access could not be obtained because the database is in use"
I tried taking UAT.Web offline but then it fails with the error "UAT.Web cannot be opened because it is offline"
Why would it matter if the database is in use when I'm using a backup? What do I need to do?
You can't restore a database that is in use because the restore would put it in an inconsistent state. You need to disconnect all active connections (including all SSMS query windows and other applications) from the database in order to restore it. If it already exists make sure to check "Overwrite existing database" on the Options tab of the restore window.
On a side note, up to you but I would recommend not using a '.' in the database name. It can get confusing when using fully qualified object names that include the database.
Go to Options and tick the 'Close existing connections to destination database' option before restoring.
I am testing to see if a SQL Server server based program can also work on AWS Cloud Server with 2016 SQL Server on the Amazon server. In order for me to test it, I need to restore 2 databases.
The first one eventually restored fine once i figured it out...restoring the database from my S3 "bucket" BAK file.
So then I tried to restore the 2nd database, using the same restore stored proceudre, and get this message:
[2017-12-28 02:44:22.320] The file 'D:\rdsdbdata\DATA\smsystemdata.mdf' cannot be overwritten. It is being used by database 'amwsys'.
[2017-12-28 02:44:22.320] File 'sm_system_data' cannot be restored to 'D:\rdsdbdata\DATA\smsystemdata.mdf'. Use WITH MOVE to identify a valid location for the file.
I can't find where to use the WITH MOVE because it won't let me restore it interactively through the Management Studio restore menu; instead I have to give it a stored procedure command:
exec msdb.dbo.rds_restore_database
#restore_db_name='sample99',
#s3_arn_to_restore_from='arn:aws:s3:::lighthouse-chicago/sample999.bak';
And each time it tells me it can't restore it because it's going to overwrite the first database's files.
Much thanks
bill
I think you are stuck in RDS's restriction.
I had the similar problem as you. Multiple restore from one DB instance is impossible at RDS.
Here is RDS's restriction you may encounter.
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/SQLServer.Procedural.Importing.html
You can't restore a backup file to the same DB instance that was used
to create the backup file. Instead, restore the backup file to a new
DB instance. Renaming the database is not a workaround for this
limitation.
You can't restore the same backup file to a DB instance multiple
times. That is, you can't restore a backup file to a DB instance that
already contains the database that you are restoring. Renaming the
database is not a workaround for this limitation.
If you are in this case, you can't use .BAK file. To avoid it, you should create DB instance with DML and import table data.
I created a Django website and filled the database with some entries. I then uploaded the site to Heroku. Later, I added more entries, but I mistakenly added them to the remote database.
I would like to (1) sync the local and remote databases (so that all the new material I added to the remote database gets copied to the local database) and (2) from now on work in such a way that I add entries to the local database first and then those entries get added to the remote database when I git push.
Any idea how to do this? Thank you.
Hi I have an sqlite database called 'main.db' where I attach all the databases that are in the directory 'db' (e.g. 'db/db1.db' , 'db/db2.db' and so on).
I would like to know if there is a way to save 'main.db' so that the attachements are remembered across sessions.
Also when in 'main.db' how can I create a new database 'db/db3.db' and have it attached automatically when I open 'main.db'?
I usually use the sqlite3 shell for my databases maintenance.
Attachments are not stored in the database; they are local to a connection.
Any attachments must be done explicitly by the application that has opened the database.