Skip to content

Instantly share code, notes, and snippets.

@amalmurali47
Last active November 7, 2024 13:03
Show Gist options
  • Save amalmurali47/c58ef024683cccd242625995b45b7b72 to your computer and use it in GitHub Desktop.
Save amalmurali47/c58ef024683cccd242625995b45b7b72 to your computer and use it in GitHub Desktop.
Backup DigitalOcean droplet locally

DigitalOcean does not provide a way to download a snapshot of your droplet locally. You can use rsync to accomplish this instead.

On your local machine, assuming you have added your-server in your SSH config:

rsync -aAXHv --append-verify --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} your-server:/
  • -a : archive mode (all files, with permissions, etc.)
  • -A : preserve ACLs/permissions (not included with -a)
  • -X : preserve extended attributes (not included with -a)
  • -H : preserve hard links (not included with -a)
  • -v : verbose, mention files
  • --append-verify: if the files differ in modification or other timestamps, it will overwrite the target with the source without scrutinizing those files further
@miwgel
Copy link

miwgel commented Jan 6, 2023

Very useful my friend, thank you 😊

@StrandedKitty
Copy link

On macos I had to slightly modify the command (note the ./ in the end that specifies dst folder):

rsync --recursive --ignore-existing --progress --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} root@ip:/ ./

@erikson1970
Copy link

Great work - thanks. I was just looking how to do this.

@0x006E
Copy link

0x006E commented Jun 1, 2023

This didn't exclude the files that were told to exclude for me. I had to create a new file (exclude.txt) listing the folders to be excluded

/dev/*
/proc/*
/sys/*
/tmp/*
/run/*
/mnt/*
/media/*
/lost+found

and then change to rsync command to:
rsync --recursive --ignore-existing --progress --exclude-from='exclude.txt' root@ip:/ ./

@epireve
Copy link

epireve commented Jun 28, 2023

Thanks!

@jor32233223
Copy link

you wont be able to restore a droplet with this can you?

I was looking to store a pre-configured droplet I dont need know to be able to lateron restore it easily.
Linode supports this digitealocean are criminals to letting us not do this, ofcourse it will hurt there business.

@RogueSMG
Copy link

Thanks mate!

@sanduvasilebogdan
Copy link

Thanks!

@qaassimq
Copy link

qaassimq commented Sep 8, 2024

is it possible to restore ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment