What's the easiest way to back up my Ubuntu VPS to my local machine? reddit / selfhosted ---------------------------------------------------------------------- Blue-Paws · 2023-11-04 15:49 Can I simply copy the files using SFTP? I'm running docker containers if that matters. Ideally, I would like this to be automatic, however, if I have to manually copy the files once or twice a month that's fine too. ---------------------------------------------------------------------- schklom · 2023-11-04 16:00 A `rsync` cronjob should do the trick and is simple. More versatile but complex setups involve e.g. `Syncthing` or `Duplicati`. ---------------------------------------------------------------------- Blue-Paws · 2023-11-04 16:01 Thanks! Can this be done on my Windows local machine, or do I need to do this on my Linux machine? ---------------------------------------------------------------------- schklom · 2023-11-04 16:15 Both will work. But you will need to open and forward the SSH port (22 by default) from your router to your local machine. Ideally, you can whitelist your VPS to avoid unwanted connections, either on your router (ideal) or on your local machine (with for example `ufw` on your Linux machine, or Windows Firewall on the other). ---------------------------------------------------------------------- lazyzyf · 2023-11-04 16:21 kopia ---------------------------------------------------------------------- dazchad · 2023-11-04 16:25 I'd do the opposite: connecting from Windows to the remote server. Don't forget to disable password login on SSH, allowing only key-based login. ---------------------------------------------------------------------- schklom · 2023-11-04 16:51 > connecting from Windows to the remote server This is what I meant with > setting up a VPN server on your VPS and connecting your local machine to it :P ---------------------------------------------------------------------- HoustonBOFH · 2023-11-04 17:00 One thing to add to what everyone else has posted. You can not back up files that are being written to... So open databases, and so on. Most backups have to have the service shut down to work properly. Also, no backup is complete if it is not tested and tested often. You do not know it will restore and run until you restore it and run it. ---------------------------------------------------------------------- dazchad · 2023-11-04 17:21 No need to setup VPN. Just ssh directly into it. SSH is already encrypted. ---------------------------------------------------------------------- schklom · 2023-11-04 18:00 Good point, that is easier ---------------------------------------------------------------------- Blue-Paws · 2023-11-04 18:22 Thank you! ---------------------------------------------------------------------- Blue-Paws · 2023-11-04 18:23 Thank you! ---------------------------------------------------------------------- Blue-Paws · 2023-11-04 18:24 Yes, I recently finally got SSH keys to start working properly. Thank you! ---------------------------------------------------------------------- Blue-Paws · 2023-11-04 18:24 I will check into this, thanks! ---------------------------------------------------------------------- joecool42069 · 2023-11-04 18:35 Running docker? forget about backing up the entire vps/os. Backup your docker-compose.yml, backup your persistent data, move on with your life. If your vps fails, you simply re-install docker engine. Copy over your docker-compose.yml and persistent data, docker compose up -d, move on with life. That simple. ---------------------------------------------------------------------- Ok_Size1748 · 2023-11-04 19:17 Borg backup is great ---------------------------------------------------------------------- Blue-Paws · 2023-11-04 19:31 This is what I was thinking originally, but there is more than just the docker-compose.yml that has settings that I'm trying to avoid redoing: .env, settings.yml, etc... There are also settings files buried in /etc/..... that I'll never find for each container. This is why I haven't just copied the folder where the docker-compose.yml file lives for each container because I know it's not enough...or is it? ---------------------------------------------------------------------- Blue-Paws · 2023-11-04 19:32 Thanks! I've heard of this. I'll have to check it out again. ---------------------------------------------------------------------- joecool42069 · 2023-11-04 19:45 i dunno what settings.yml thing you're referring to. afaik there's no docker settings.yml. yes, you'd want to backup your .env along with your docker- compose.yml. If you're doing docker right, there should be no setting files buried in /etc. unless you're doing volume binds there? but again, you'd just need to copy over your persistent data. If you're using named volumes, by default they're in... /var/lib/docker/volumes. personally, i don't like my volume data in /var/lib. i like to set my volume locations either with the local driver like this: volumes   myvolume:     name: myvolume     driver: local     driver_opts:       type: 'none'       o: 'bind'       device: '/my/volume/location'volumes or with a bind mount like this: services:   mycontainer:     container_name: mycontainer     volumes:       - /my/persistent/container/data/location:/app/data ---------------------------------------------------------------------- SillyLilBear · 2023-11-04 20:03 I'm a big fan of restic to S3 compatible storage. ---------------------------------------------------------------------- rafipiccolo · 2023-11-04 20:48 I'm interested. If I copy a MySQL database while it's running using rsync and starting this backup. Is this different from rebooting MySQL after a power failure ? ---------------------------------------------------------------------- HoustonBOFH · 2023-11-04 21:44 If you copy a MySQL database while it's running using rsync and starting this backup, your chances of having anything useful at the end are about the same as winning the MegaMillions jackpot. You need to shut it down and copy, or export the database and copy that. ---------------------------------------------------------------------- xkcd__386 · 2023-11-05 04:14 lots of good answers to your main question, so let me address something that I have not seen addressed in the comments so far: > once or twice a month this is not a backup, unless the data is static and unchanged for long periods of time. I suggest daily at least, which in turn means automation is required. ---------------------------------------------------------------------- elusiveporcupine · 2023-11-05 10:24 Kopia with the built-in support for Rclone is great - highly recommended.