Errors 3154 and 3159 are SQL Server stopping you from overwriting an existing database. They are safety checks, not faults. The right fix depends on whether you actually want to replace that database.
The errors
The backup set holds a backup of a database other than the existing 'Sales' database.The tail of the log for the database "Sales" has not been backed up.
Use BACKUP LOG WITH NORECOVERY to back up the log if it contains work you do not want to lose.
Use the WITH REPLACE or WITH STOPAT clause of the RESTORE statement to just overwrite the contents of the log.3154 means the backup is from a different database than the one you are restoring over, for example a backup of Sales_Test restored onto Sales. 3159 means the target database is in FULL recovery and has recent transactions that are not in any backup. Restoring would discard them.
Option 1 (safest): restore under a new name
Nothing is overwritten, and you can compare before deciding anything. Get the logical file names with RESTORE FILELISTONLY, then:
RESTORE DATABASE [Sales_20260927]
FROM DISK = N'D:\SQLBackups\Sales_FULL_20260927.bak'
WITH MOVE N'Sales' TO N'E:\SQLData\Sales_20260927.mdf',
MOVE N'Sales_log' TO N'E:\SQLLogs\Sales_20260927_log.ldf',
STATS = 10;Option 2: keep recent work with a tail-log backup (error 3159)
If the existing database has changes you may need, back up the tail of the log first. NORECOVERY leaves the database in a restoring state, ready for your restore:
BACKUP LOG [Sales]
TO DISK = N'D:\SQLBackups\Sales_TAIL_20260927.trn'
WITH NORECOVERY;Now restore your backups. You can apply the tail-log backup last to recover right up to the moment you started.
Option 3: overwrite on purpose with REPLACE
Use this only when you are sure the existing database and its unsaved changes can be thrown away:
ALTER DATABASE [Sales] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
RESTORE DATABASE [Sales]
FROM DISK = N'D:\SQLBackups\Sales_FULL_20260927.bak'
WITH REPLACE, STATS = 10;
ALTER DATABASE [Sales] SET MULTI_USER;It overwrites the database even if the backup came from a different database. Double-check the file name and RESTORE HEADERONLY output before running it on a production server.
In SSMS
On the Restore Database dialog's Options page, Overwrite the existing database (WITH REPLACE) corresponds to option 3, and Take tail-log backup before restore to option 2. Changing the destination database name on the General page is option 1.
With Velocity
Velocity avoids this situation by design. If a database with the same name already exists, it restores the backup under a new, date-stamped name instead of replacing it, so a restore never overwrites a live database.