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.

4
  • are you looking to take entire system backup ? something like image backup ? clonezilla.org
    – Kamaraj
    Nov 1, 2016 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. Nov 1, 2016 at 8:26
  • did you check the clonezilla.org ?
    – Kamaraj
    Nov 1, 2016 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. Nov 2, 2016 at 16:22

2 Answers 2

7

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

4
  • 1
    Would you please explain why tar is better? Nov 1, 2016 at 10:15
  • 1
    tar will retain Unix file permissions plus other metadata - very useful when restoring an entire system after a disaster! Nov 2, 2016 at 15:17
  • 1
    I know that. It is a suggestion to improve the post. Nov 2, 2016 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! Nov 2, 2016 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.

1
  • 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. Nov 2, 2016 at 16:26

You must log in to answer this question.

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