Backup remote linux machines to Synology

The Purpose

I use a number of Virtual Private Servers (VPS) and wanted to make a backup of the data and applications running on them.

The first step is to make a local copy of your data to a folder on the remote machine, then you can pull these files to the Synology NAS via a scheduled task. For my applications I simply used tar to backup all the directories I can about to a single file and a mysql dump to dump all the databases in the mysql server to a single file.

Setup Authentication

generate your keys


#ssh-keygen

  • do not configure with a password

Verify sshd is configured to use key files


vi /etc/ssh/sshd_config


AuthorizedKeysFile      %h/.ssh/authorized_keys

Add the public key to ssh authorized_keys


cat key.pub >> ~/.ssh/authorized_keys

Copy the private key to the Synology

Use any method you like for this. I personally simply copied the contents of the private key, then pasted it into a file on my local machine and moved it to an existing share on the NAS.

Connect to source machine from Synology and trust the source machine


chmod 400 $AbsolutePathToPrivateKey
ssh -p 22 -i $PRIVATEKEY your-user-name@server.your-domain.com

The scheduled task

Create the scheduled task

save the script below local to the Synology and make it executable

notes:

  1. You may need to enable SSH terminal access on your NAS.
  2. If you edit the script locally on a windows machine with Notepad ++ make sure you change the EOL (End of Line) to Unix


#!/bin/bash
USER="your-user-name"
SERVER="server.your-domain.com"
PORT="22"
SSHID="/volume1/backups/scripts/certificates/server.your-domain.com.privkey.pem"
SOURCE="/backups/synology/"
TARGET="/volume1/backups/server.your-domain.com/"
LOG="/volume1/backups/server.your-domain.com/backup.log"
/usr/bin/rsync -avz --progress -e "ssh -p $PORT -i $SSHID" $USER@$SERVER:$SOURCE $TARGET >> $LOG 2>&1

Run the script and verify your data is copied

References

http://raphael.kallensee.name/journal/how-to-backup-an-external-server-with-a-synology-nas-via-rsync/

Windows computers not reporting to WSUS

Verify client configuration

Local Computer Policy

Verify Resultant Policy is correct

Verify Correct GPO’s are being applied

C:\>gpresult /scope computer

Update Group Policies

C:\>gpupdate /force

verify connectivity

ping wsus-server-01.domain.com

telenet wsus-server-01.domain.com 8530

If you are using a hosts file and having troubles with resolution, check out this post

Reset the client

wuauclt.exe /resetauthorization /detectnow

Force check in

wuauclt.exe /reportnow

Check WSUS in 10-15 minutes

If you are still having issues check out the client log file:

C:\Windows\WindowsUpdate.log

Windows hosts file not being used for resolution

windows version: Server 2003 R2 Standard x64 SP2

Verify it’s not working

ipconfig /flushdns

ipconfig /displaydns | more

Check for type-o’s!

Start with the simple solution first

Verify hosts file location

Open Registry Editor

Verify key: My Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services|Tcpip\Parameters\DataBasePath

Copy Value data and paste it into Explorer to verify you are editing the correct file

Verify file permissions (This was my issue)

If machine\users is not given Read and Read & Execute permissions, add the account.