We have prepared a piece of software that creates a clone of our production database (SQL Server) that contains only the most recent data. We would like to allow developers to instantly create a development environment on their computers.
The first step of the process involves copying table schemas and predefined data. This step takes around 7 seconds. Since this is a production database, users might be committing transactions during these 7 seconds. We would like to prevent the users of doing so, in order to avoid errors that might arise when creating the foreign key constraints at the next step of the cloning process.
We have examined the possibility of making the database temporarily READ_ONLY
, but this would drop all connections to the database. This is not desirable because it causes a lot of side effects. We would like to know if there is a query that puts a write-lock on every table of the database, until we decide to manually release the lock. Ideally, we would like the user to just experience a delay on their request, rather that a connection drop.
We have used database backups in the past. The problem is the database size. At the moment it is 17 GB and constantly growing. Even after compression, We have at least 1GB to transfer through the internet. Our internet connection is slow, and offers about 0.5MB/sec upload speed, and this cannot be overcome. Additionally, we would not like to give away all our data.