Coolest Guides on the Planet

coolest guides on the planet

Coolest Guides On The Planet

  • Home
  • macOS
  • WebDev
  • All Posts
  • Contact

Back up a VPS Web Host using SSH and SCP on Mac OSX 10.6

July 19, 2011 Leave a Comment

Using SSH and SCP you can copy your remote web VPS backups to your local machine in a secure manner and then by creating a back up script you can either run the script adhoc or schedule the process with a user launch agent.

The first step is to create a SSH passwordless connection between the vps webserver and the local machine, this is done by adding the public SSH key of the local computer to the ‘authorised_keys’ file of the remote VPS host.

Once this is done you can SSH into your remote VPS host without a password prompt.

Test that the connection works with no password

local:~ user$ ssh root@hostingserver.com

Last login: Mon Jul 18 12:58:53 2011 from 12.34.567.890
root@hosting [~]# exit 

Once the connectionless communication is established you can use ‘scp’ to securely copy your backup to your local machine, ‘scp’ runs in the ‘ssh’ protocol so the connection is encrypted. Find out the path from your web host where the backups are filed. In this example they are at the root level ‘/backups’.

So to copy over the archived backups the command below will recursively copy the ‘/backups’ directory on the remote host to the local users desktop directory.

local:~ user$ scp -R root@hostingserver.com:/backups ~/Desktop

The first part of this command is the ‘from’ directory and since it is the remote host, the ssh connection string is used separated by a ‘:’ then the remote path and the second part of the command is the ‘to’ directory which is our desktop folder on our local host.

Once you have tested and verified that the copy is made sucessfully , it’s worthwhile make a simple script that you can run adhoc.

Create a script using your from and to destinations and and save it as ‘backup.sh’:

#!/bin/bash
scp -R root@hostingserver.com:/backups ~/Desktop

Save it in /usr/sbin and give it the ownership and permissions of the below
-rwxr-xr-x 1 root wheel 269B Jul 14 10:15 backup.sh
Reload the shell to apply the new command:

source ~/.bash_profile

Then run the command from the command line

local:~ user$ backup.sh

One final thing to do is to schedule the script to run at a frequency – you can create a launch agent in your home library and set that to run weekly or monthly.

Cats: macOS Tags: backup, OSX, scp, script, ssh, vps

Tags

3gs 10.6 apache backup baseband boot clean urls cpanel css curl custom database drupal el capitan git Google image instadmg ios iphone jailbreak keys lion mac macos mojave macos sierra menu mysql OSX panda php phpmyadmin private public redirect redsn0w remote rsa SEO shell ssh terminal unstoppables upgrade urls

Donate a Beer to the Coolest Guides

Get Beaver Builder Now!

Copyright © 2023· Neil Gee - All Rights Reserved - Hosted by Runcloud

Copyright © 2023 · gee on Genesis Framework · WordPress · Log in