Restoring your installation from a backup

If you manually created a backup of your Lansweeper installation, you can always restore it at a later date if necessary. Which restore procedure you should follow depends on which database server you are using, Microsoft SQL Compact or Microsoft SQL Server. If you perform an Easy Install, your database is hosted in SQL Compact. If you perform an Advanced Install, your database can be hosted in SQL Compact or SQL Server. If you are unsure which database server you are using, browse to the following section of the web console: Configuration\Your Lansweeper License

checking which database server is being used

Restoring a backup if you are using SQL Compact

To restore your installation from a backup if your database server is SQL Compact, do the following:

  1. Stop the Lansweeper Server service in Windows Services
    stopping the Lansweeper Server service
  2. Stop your web server service in Windows Services. Keep in mind that this will log everyone out of the console. Your web server service is either IIS Express or World Wide Web Publishing Service (IIS).
    stopping the web server service
  3. Make sure your database backup file is called lansweeperdb.sdf and place it in the following folder, overwriting the database file currently present in the folder:
    Program Files (x86)\Lansweeper\SQLData
  4. Restore the Website subfolders and Encryption.txt file you created a backup of.
  5. Restart the Lansweeper and web server services in Windows Services.

Restoring a backup if you are using SQL Server

To restore your installation from a backup if your database server is SQL Server, do the following:

  1. Stop the Lansweeper Server service in Windows Services
    stopping the Lansweeper Server service
  2. Stop your web server service in Windows Services. Keep in mind that this will log everyone out of the console. Your web server service is either IIS Express or World Wide Web Publishing Service (IIS).
    stopping the web server service
  3. Right-click the lansweeperdb database in SQL Server Management Studio and select Tasks\Restore\Database... to open the restore wizard. If SQL Server Management Studio isn't installed on your Lansweeper server, we recommend downloading it online. (You will need to perform a search for the Management Studio that's compatible with your particular edition and version of SQL Server.)
    database restore task in SQL Server Management Studio
  4. In the General tab of the restore wizard, select the correct destination (lansweeperdb) and source for the restore operation. If your backup is a .bak file, select the Device option under Source and hit the button with the three dots to open a popup where you can select your file.
    database restore source in SQL Server Management Studio
  5. In the Options tab of the restore wizard, tick Overwrite The Existing Database. Hit OK to perform the database restore.
    Overwrite The Existing Database in SQL Server Management Studio
    Make sure the overwrite box is checked. Otherwise, the following error may be generated: "The backup set holds a backup of a database other than the existing 'lansweeperdb' database."
  6. Execute the script below in SQL Server Management Studio to reset the lansweeperuser SQL user used by the Lansweeper service and web console to connect to the database. Replace what's marked in bold with the password you want to set for lansweeperuser, leaving the single quotes in the script.
    /* Makes sure there are no objects in the lansweeperuser schema, so the lansweeperuser SQL user can be reset */
    USE lansweeperdb
    GO
    DECLARE c_ALTSCHEMA CURSOR FOR
    SELECT 'ALTER SCHEMA dbo TRANSFER lansweeperuser.'+name +';'
    FROM sys.objects
    WHERE SCHEMA_NAME(SCHEMA_ID) = 'lansweeperuser'
    DECLARE @SQLStmt NVARCHAR(200)
    OPEN c_ALTSCHEMA
    FETCH NEXT FROM c_ALTSCHEMA INTO @SQLStmt
    WHILE @@FETCH_STATUS = 0
    BEGIN
    EXEC(@SQLStmt)
    FETCH NEXT FROM c_ALTSCHEMA INTO @SQLStmt
    END
    CLOSE c_ALTSCHEMA
    DEALLOCATE c_ALTSCHEMA
    GO

    /* Resets the lansweeperuser SQL user */
    USE lansweeperdb
    GO
    DROP SCHEMA lansweeperuser
    GO
    DROP USER lansweeperuser
    GO
    EXECUTE sp_droplogin lansweeperuser
    GO
    USE MASTER
    GO
    EXEC sp_addlogin 'lansweeperuser', 'lansweeperuserpassword', 'lansweeperdb', [English]
    GO

    USE lansweeperdb
    GO
    EXEC sp_grantdbaccess 'lansweeperuser', 'lansweeperuser'
    GO
    EXEC sp_addrolemember [db_owner], 'lansweeperuser'
    GO

    Don't skip this step! Restoring a database backup almost always corrupts the SQL user used by the Lansweeper service and web console to connect to the database. If you don't reset the user, the service and web console will be unable to connect to the database.
  7. Run the following tool on the server(s) hosting your Lansweeper Server service and web console:
    Program Files (x86)\Lansweeper\Tools\ConfigEditor.exe
    ConfigEditor tool
  8. Click through any warnings the tool may be giving you about your password being incorrect.
  9. Select the Password field and hit the Edit button.
    using ConfigEditor to update the Lansweeper Server service password
  10. Submit the same password you previously used in the database script and hit the Save button.
  11. If the ConfigEditor tool has multiple tabs due to your server hosting multiple Lansweeper components, select the other tab, click through any warnings and repeat the password changing process.
    using ConfigEditor to update the web console password
  12. Restore the Website subfolders and Encryption.txt file you created a backup of.
  13. Restart the Lansweeper and web server services in Windows Services.
  14. If you have multiple scanning servers, update the database password on those servers as well by stopping the Lansweeper service, using the ConfigEditor tool and restarting the service.

Related Articles