Powershell script for sysadmin to regularly download backups from server to computer

For anyone reading this, here are better/more up-to-date instructions since I slightly struggled with the OP’s instructions:

1)Make/Use a folder where this script will be stored. Then, create a folder called backup within that folder.
2)Copy/paste the script in Notepad. NOTE: If using a VPS, use your VPS’ username and the public IP address for the $ssh_address = "username@your.site" line. Save As anyname.ps1 and don’t forget to set the drop-down box to “All Files,” as shown below.
hhhh

3)Press Windows Key ⊞ and type in “Tasks,” then click “Task Scheduler.”
4)On the right-hand side, click “Create basic task.”
5)Give any name/description.
6)Pick if you want daily/weekly/yearly/etc. I recommend Daily.
7)Set the date & time you want to do this. Keep Recur at 1. Make sure you go into your Discourse site’s Admin settings > Backups. Check the box next to automatic backups enabled.
Then, set backup frequency to whatever you want. I recommend 1 but the key here is to have it match up with your Task Scheduler settings. Make the backup dates match up. Example: if you set Task Scheduler to backup Daily, set your Admin Backup backup frequency settings to 1.
8)Leave default setting at “start a program” and click Next.
9)Click Browse and find the script you saved. Click Next.
10)Click Finish.
If you want to test it, right-click the script and choose “Run with Powershell.”

Note: If you get “the system cannot find the file specified,” then enter your password like it shows on PowerShell and it will find it anyway.

1 Like