cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
mkergan
Engaged Sweeper
Is there a Powershell script that I can run to automate my backups of Lansweeper?
2 REPLIES 2
Brown_Dog_NG
Champion Sweeper

Dead thread, sorry to reopen but wanted to contribute.

If using SQL 2016, you may reference this site. Reference Step 2. I've extracted the steps in the event the link goes bad.

1. Log into your SQL Server via Microsoft SQL Server Management Studio
2. Right-click SQL Server Agent, select Start to enable this function.
3. Open up SQL Server Agent tab, right-click Job > New Job…
4. On General page, fill the name in the blank.
5. Turn to Step page, click New… and fill in Step name in the prompt window. Select T-SQL in Type, then input following statements in Command:>

DECLARE @strPath NVARCHAR(200)
set @strPath = convert(NVARCHAR(19),getdate(),120)
set @strPath = REPLACE(@strPath, ':' , '.')
set @strPath = 'filepath' + @strPath + '.bak'
BACKUP DATABASE [databasename] TO DISK = @strPath WITH NOINIT , NOUNLOAD , NOSKIP , STATS = 10, NOFORMAT

Note: as for the ‘filepath’ part you need to fill in the path created before to store these backups. For example: D:\Backup.
Then click OK.>

6. Turn to Schedules page, click New… and fill in Schedule name, select the Frequency and Duration in the prompt window. Click OK to save these settings.
7. Find the newly created job in SQL Server Agent > Jobs, right-click it and select Start Job at Step to start.
-Don't forget to hand out Kudos and mark Solutions to replies you receive!-
LS Tech Support Email: Support@lansweeper.com
LS Tech Support KB: https://www.lansweeper.com/contact-support/
ErikT
Lansweeper Tech Support
Lansweeper Tech Support
Hi mkergan,

There is no PowerShell script currently available to backup your Lansweeper database.

I's suggest having a look at the below link to help you create one for your LS installation.

https://www.sqlservercentral.com/articles/backing-up-sql-server-databases-is-easier-in-powershell-than-t-sql