-1

I'm using a Ubuntu 14.04.4 LTS on my server. Is there a way to zip everything on the server in a single archive, preferably with a single command?

I've tried using

zip -r backup.zip

but that doesn't work, since I'm not providing it with what I would like to zip. I have also tried using

zip -r backup.zip *.*

but that only zips the files, and not the directories.

I am aware that I could go with

zip -r var.zip var
zip -r root.zip root
zip -r media.zip media
etc

Since that would be time consuming, I'm looking for an easier solution, if it exists.

EDIT Use of 3rd party software, like Clonezilla, is not allowed. I have to find a command line solution.

  • are you looking to take entire system backup ? something like image backup ? clonezilla.org – Kamaraj Nov 1 '16 at 8:15
  • Something like that, yes. I just want to have it around, so I can experiment on it, for example, on a local server. – FiddlingAway Nov 1 '16 at 8:26
  • did you check the clonezilla.org ? – Kamaraj Nov 1 '16 at 8:26
  • I did. Unfortunately, any kind of 3rd party solutions are of no use. I am limited to command line use with the stuff that's already on the server. My bad, I should have stated that in the original question. – FiddlingAway Nov 2 '16 at 16:22
5

You'd be better off creating a compressed tarball archive.

A typical command for doing this for an entire system is...

tar -cvpzf /backup.tar.gz --exclude=/backup.tar.gz --one-file-system /

See https://help.ubuntu.com/community/BackupYourSystem/TAR

  • 1
    Would you please explain why tar is better? – Rui F Ribeiro Nov 1 '16 at 10:15
  • 1
    tar will retain Unix file permissions plus other metadata - very useful when restoring an entire system after a disaster! – Andy Foster Nov 2 '16 at 15:17
  • 1
    I know that. It is a suggestion to improve the post. – Rui F Ribeiro Nov 2 '16 at 15:21
  • This seems to be what I'm looking for. I'm testing it as I'm typing this, and everything works as I'd hoped. Thank you! – FiddlingAway Nov 2 '16 at 16:29
0

I am assuming that you want to zip every file and folder that is present in your server to a single zip file. You can do it like

zip -r backup.zip /

The '/' stands for the root of the file system in linux. So the above command will start from the root and will zip all folders and files recursively. But if you are really interested to have a backup of your system, there are far more better options than zipping files and folders.

  • Sorry for the late reply. I have tried your suggestion. Unfortunately, some of the files are ignored - i get the zip warning: ignoring special file:... Also, the process gets killed after 50-60 files. – FiddlingAway Nov 2 '16 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.