1

I have an Ubuntu 18.04 VPS on a hosting company.

I manage it via web panel and SSH from my Windows 10 client.

I would like to full remote backup my VPS for possible future restore.

How can I do from a Win client ?

Thanks

2
  • Check this link - addictivetips.com/ubuntu-linux-tips/… Mar 26, 2019 at 15:50
  • What all applications etc. are you using on this VPS? With just the information you've posted so far I would say Overmind's answer is the best bet. Bacula is a very mature FOSS solution for backup/restore and should work in your situation. Mar 29, 2019 at 6:17

4 Answers 4

4
+50

Basics

In most cases, you have 3 things to backup:

  1. Files uploaded by your VPS clients (i.e. Media files in Wordpress)
  2. Your database(s)
  3. The Linux setup (a.k.a. files under /etc)

Anything else is static data and yous should not have to back it up. (i.e. you can recover it by reinstalling the system and your tools/software)

Local Backup with All Properties

Assuming you have enough space on your VPS hard drive, you can first create tarballs of your data, as you see fit. For example, I create one per database so I can restore that specific database and have one large file with everything in it.

# for files
tar cf - /path/to/folder/to/backup | xz -9 > /home/backups/my-files.tar.xz

# for databases
mysqldump db_name | xz -9 > /home/backups/my-database.sql.xz

Place those in a folder (/home/backups in my example here; Ubuntu has /var/backups, for example) and then with SSH (or SFTP) do a transfer.

scp vps:/home/backups/my-files.tar.xz C:\Backups
scp vps:/home/backups/my-database.sql.xz C:\Backups

Multiple Backup Files

Further, you can (probably want to) automate everything. In that case I would strongly suggest that you look into using a date in the filename:

DAY_OF_WEEK=`date + %u`
tar cf - /path/to/folder/to/backup \
             | xz -9 > /home/backups/my-files-${DAY_OF_WEEK}.tar.xz

This way you get 7 different files and when you do the transfer you can choose the correct file each time. Also it gives you a few days to detect a problem. You can of course use %d, but remember that uses a lot of space on your VPS. Make sure that if you increase the number of backups you will not overflow your available disk space.

Note that the tar utility and mysqldump will save all the necessary information to restore the files as required.

Transfer

Finally, to do the transfer. You can use SSH or, to make sure you get the latest version, you could use cwRsync. This will get you the files that have changed without you having to do much.

rsync <options> C:\Backups vps:/home/backups

Check the rsync docs for the proper . There are many of them. Test well to make sure you get them right.

Note: I use rsync between my Linux boxes, with compression, it works well. However, it would probably not work well between Linux and MS-Windows (Users Names, Permissions, etc.). This is why I suggest you first create tarballs and database dumps as mentioned above. It's a good idea to have tarballs anyway because they can be well compressed. Note that for databases, a dump is the easiest way to make sure you get a correct snapshot.

Security

When automating, you need a key without a password. Otherwise you'll have to be at your computer whenever the rsync or SSH transfer starts... not practical.

In order to allow for such, I create a special user that will have his own account (a.k.a. /home/backups, user is named backups... hint hint!) I create a key without a password and that user has minimal rights on the Linux box. Mainly, it can only read data... For sure, no sudo or other such advanced permissions.

The backup files can even be created under /home/backups with a user such as root and thus can't be tempered by backups, only read for the transfer. That way you know that those files are safe.

Final Step

Now it looks like you have a fully automated backup...

Well! Please make sure that the files look correct. Even, if you have time, attempt a restore. It's going to be manual, but hopefully you'll never need those backups. (I rarely need mine and I like it that way!)

Replication for Backing Up Systems

You may also be interested in a more advance topic: replication. This is where you create a VPS second instance and get all the data duplicated between both computers. I know of Hadoop, for example. However, I'm not so sure that it would work well between Linux & MS-Windows, hence the second VPS as a backup... Some database systems come with such replication, like Cassandra. PostgreSQL and MySQL also have replication mechanism that can be used for backing up your data. Those would work between a Linux VPS and MS-Windows. However, it probably requires your MS-Windows computer to be up and running at all time.

So, with Hadoop replicating your folders and setting your database with replication, you could also achieve your replication. It's just much more work to make it all work as expected... (and you have other potential security issues arising.)

1

Since it's a VPS you have access to everything and you can install all the software you need. Any solution of your choice can work, but setting up something like rsync would of been nice if you were to have a linux server to back it up to.

Since you deal with a Windows client, you could use something like Bacula. It is an Open Source Backup Software which does not require intervention from an admin once setup. Bacula supports Linux, UNIX, and Windows backup clients. Administrators and operators can configure the system via a command line console, GUI or web interface.

1

Have you tried FTP, that should do the job. Use vsftpd as the server and FileZilla client or file explorer's built in FTP client.

To install vsftpd in Ubuntu, run the following:

sudo apt install vsftpd

Note: The login is your Ubuntu login, you will start in your home directory where you can navigate to root directory.

2
  • FTP it's ok, but a backup like that, will be mantain file owner etc ?
    – stighy
    Mar 29, 2019 at 8:54
  • @stighy, newer versions of FTP have all the necessary to maintain all the metadata, however, that is not likely to work well under MS-Windows. Especially, you would probably be missing all the Linux default users... Mar 30, 2019 at 20:36
1

FTP is a good option, But since you already have SSH access you can use SFTP too. If you are using a ssh-client like Bitvise on windows, Then you can easily get an SFTP window and copy any file you want from your VPS into any local folder on your windows client.
But FTP is the more standard option.

Also, There are other options. This link should help

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .