Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Backup Server to Desktop

backup

  • Please log in to reply

#1
Andy1953

Andy1953

    New Member

  • Member
  • Pip
  • 4 posts

Hi Geeks,

 

I recently hired a geek to tweak a script  that is supposed to download the contents of my server to my local Mac, which runs Ventura.

 

My server is a VPS hosted by Contabo.com.
The VPS runs Virtualmin/Webmin.

 

The script is supposed to copy the contents of the server, minus a few unnecessary items, into a folder on my local hard drive named Server-Whole-Latest.

 

However, the hired geek somehow managed to either misunderstand me, or incompetently provided a formula that backs up the server into a folder named Server-Whole-Latest on the server!!

 

Here's what I paid for:

 

BACKUPDIR="Server-Whole-Latest/"

sudo /usr/bin/rsync -avxz                \
    --rsync-path="sudo rsync"        \
    --delete                \
    --numeric-ids                \
    --relative                \
    --delete-excluded            \
    --exclude="/dev/"            \
    --exclude="/proc/"            \
    --exclude="/run/"            \
    --exclude="/sys/"            \
    --exclude="*/tmp/**"            \
    --exclude="/tmp/**"                     \
    --exclude="*.log"            \
    --exclude="/var/log"            \
    --exclude="*.wpress"            \
    --exclude="*.wpstg"            \
    --exclude="Backups-of-WP/**.tar"    \
    --exclude="updraft/backup*.zip"        \
    --exclude="backups/*.zip"        \
    --exclude="snapshots/*.zip"        \
    --rsh="/usr/bin/ssh -p 2610"        \
    [email protected]:/ ${BACKUPDIR}

 

 

With my kindergarten level of coding knowledge, I can see that the very first line selects the backup directory, but I need to know how to change that location to my local hard drive.

 

Thanks for your geekism.

 

Andy Scott


Edited by Andy1953, 13 May 2023 - 04:37 PM.

  • 0

Advertisements


#2
Spike

Spike

    nOoB

  • Member
  • PipPipPipPip
  • 1,357 posts

Good morning Andy,

 

Just so I can confirm you're trying to backup your "server" to your "local" system? Is that correct?

 

The script currently resides on your Mac correct?

With the assumtion of the script running on your Mac, the current "BACKUPDIR" is suppose to be the location you would like to store your server backups onto your local system (Mac). So maybe it'll make it clearer by setting the backup location to a fully validated path on your local system (Without the full path the script will look inside its current directory for the folder where you script resides):

BACKUPDIR="/somepath/onmy/mac/Server-Whole-Latest/"

So as you can see in the example specify the path on your Mac where you would like to store your server backup contents. Eg: /Users/Andy/Server-Backup/

 

Make sure the folder "Server-Backup" already exists on your local Mac at the relevant path.

 

That should pretty much do it.

 

Also worth a note you've provided what seems to be your real server IP (I confirmed it's pingable on myside), I would recommend editing your thread and putting a hypethetical IP address in there instead of your real one since this is a public forum.

 

Once you're happy with the adjustment you just need to run the script on your local Mac, provide your SSH credidentials and then it'll sync the server contents to the "Server-Backup" folder on your local Mac.

 

Let me know if you have any other questions or if you run into problems.

 

Edit: Just to add some 2 cents... The script seems reasonable and should have worked, the only assumption I can make is that you're running the script on the server itself and not your local Mac system, that's why it's making the backup on the server and not your local Mac. If you were to run the script locally it's essentially creating a remote shell on your local system and copying the content over from the server; You need rsync locally on your Mac.

 

Regards,


Edited by Spike, 13 May 2023 - 12:33 AM.

  • 0

#3
Andy1953

Andy1953

    New Member

  • Topic Starter
  • Member
  • Pip
  • 4 posts

Thanks for your meaningful response, Spike.

 

I changed my IP address, as you suggested.

There's certainly no shortage of hackers these days.

 

I edited the destination directory as you suggested, but must have some error in the syntax, because this is the result:

 

rsync: mkdir "/Users/Andy/Server-Whole-Latest" failed: No such file or directory (2)

 

That folder certainly does exist, in the location I believe I specified.

 

Are you able to tell me what to tweak?

Maybe I haven't told Terminal where the destination is exactly, in words of one syllable, :spoton:


  • 0

#4
Spike

Spike

    nOoB

  • Member
  • PipPipPipPip
  • 1,357 posts

Good morning Andy,

 

Apologies for the delayed reply.

 

Could you please type the command and send the output here

ls /Users/Andy/Server-Whole-Latest

This will just determine that the path does indeed exist.

 

Another suggestion for potential debugging is running the command directly on the CLI instead of running the script. 

sudo rsync -avz --rsh="/usr/bin/ssh -p 2610" [email protected]:/home/myfolderexample/ ./

So create a folder "myfolderexample" in the /home/ directory named "myfolderexample" on your server and put a test file in it. Then run the above command to just confirm atleast that single file gets synced. This command you will run on your local system similar to how the script would have run. The file should download to the path your CLI is currently in and also don't forget to change the IP to your server address.

 

Let me know how it goes, but the idea here is to avoid back and forths is to confirm the basic query runs first then add each argument as you go along to ensure one of the arguments arn't resulting in the failed run. Then once you're happy it works, copying and pasting that full command in your script should work fine.

 

If the command runs on the CLI but fails with in the script it means there's something wrong with the script itself and may be missing elements I'm unfamilir with. Worth noting I'm not a mac user but given it's UNIX nature I'm assuming it similar to any other linux based system, but maybe Mac needs some additional info in the script (Eg. you need to specify the interpreter at the top of the script file:

#!/bin/bash

Also maybe play around with different folder paths, etc to see if you can get the command to run in its most basic form and add the more complex arguments as you go along. Let me know how it goes.

 

Regards,


Edited by Spike, 15 May 2023 - 11:15 PM.

  • 0

#5
Andy1953

Andy1953

    New Member

  • Topic Starter
  • Member
  • Pip
  • 4 posts

Thanks so much for your expert attention, Spike.

I'll follow your suggestions and let you know the results.


  • 0






Similar Topics


Also tagged with one or more of these keywords: backup

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP