Figured I'd share a little something I whipped up to push backups to Amazon's S3 storage service:

BackupToS3:
# Set your AWS credentials (replace 'YOUR_ACCESS_KEY_ID' and 'YOUR_SECRET_ACCESS_KEY' with your actual credentials)
$awsAccessKeyId = 'YOUR_ACCESS_KEY_ID'
$awsSecretAccessKey = 'YOUR_SECRET_ACCESS_KEY'
$awsRegion = 'us-east-2'  # Replace with your desired AWS region

# Set the source and destination paths
$sourceDirectory = 'C:\servuo\Backups\Archived'
$destinationBucket = 'backups'

# Set the S3 destination path (you can customize this as needed)
$destinationPath = 'archive/'

# Set the AWS credentials
Set-AWSCredential -AccessKey $awsAccessKeyId -SecretKey $awsSecretAccessKey -StoreAs MyCredential #-Region $awsRegion

Set-AWSCredential -ProfileName MyCredential

# Set the default AWS region
Set-DefaultAWSRegion -Region $awsRegion

# Get the most recent file in the source directory
$mostRecentFile = Get-ChildItem -Path $sourceDirectory -Attributes !Directory *zip | Sort-Object LastWriteTime -Descending | Select-Object -First 1

# Upload the most recent file to S3
Write-S3Object -BucketName $destinationBucket -Key "$destinationPath$($mostRecentFile.Name)" -File $mostRecentFile.FullName -CannedACLName private

Write-Host "File '$($mostRecentFile.Name)' uploaded to S3 bucket '$destinationBucket' at path '$destinationPath'"

Edit the first code block (three lines) to match you AWS credentials & region. You can easily google how to create an S3 account, get an access key, pick a region, and create a bucket. Plenty of tutorials out there so I won't go over it here.

Next, specify the folder where ServUO puts your Archived backups on your host and the name of the "bucket" you created on S3.

It's pretty much that simple! I schedule this to run every hour to pull the newest file in the ...\Archived folder and push it up to S3 so we always have a backup that's no more than an hour old separate from the server itself. You can use the built in Task Scheduler for Windows Server 20XX. Some things to note if using Task Scheduler:

- On the General tab, make sure to select "Run whether user is logged on or not" and uncheck "Do not store password..." It'll prompt you when you save it to enter your username/password and use those credentials to run the task. I always check "Run with highest privileges" too just to be safe.
- On the Triggers tab, create a new Trigger "On a schedule" that runs Daily at a specific time (doesn't matter). Specify that it should recur every 1 days, then under the Advanced settings, check the box for Repeat task every: 1 hour for a duration of: Indefinitely. I like to check the box for Stop task if it runs longer than 30 minutes (go definitely go shorter) and then make sure the Enabled box is checked.
- On the Actions tab, create a new Action using "Start a program". In the program/script, enter powershell then use in Add arguments: -File C:\[whatever your path is to where you saved the script].ps1
- Finally, on the Settings tab, I check the boxes for "Run task as soon as possible after a scheduled start is missed", then "If the task fails, restart every:" 1 minute (attempt to restart up to 3 times); Stop if task runs longer than: 1 hour; If the running task does not end when requested, force it to stop.

Hopefully that's easy enough to follow and makes for a quick and easy backup solution!
Oh! You do need the AWS plugin for PowerShell which I believe can be installed with this command:
C#:
Install-Module -Name AWSPowerShell -Force -AllowClobber
 
Back