tar Archives - Bitbandits blog https://www.bitbandit.net/tag/tar/ Just another tech blog. Fri, 11 Jun 2021 18:07:03 +0000 en-US hourly 1 https://wordpress.org/?v=6.2.6 Using tar to backup and move your website https://www.bitbandit.net/2019/10/using-tar-to-move-your-website/ Wed, 02 Oct 2019 21:52:13 +0000 https://www.bitbandit.net/?p=36 Lets say you want to move your website from one server to another. One way you can attack this project is with tar. Tar will take a directory that you give it and put it into a single file and optionally compress it. Creating a tarball On the server that currently has your website you … Continue reading "Using tar to backup and move your website"

The post Using tar to backup and move your website appeared first on Bitbandits blog.

]]>
Lets say you want to move your website from one server to another. One way you can attack this project is with tar. Tar will take a directory that you give it and put it into a single file and optionally compress it.

Creating a tarball

On the server that currently has your website you would want to run the following command. We are assuming that your website is stored in /var/www/html.

$ tar -zcvf website-backup.tar.gz /var/www/html/

This will create a tarball in your current working directory named website-backup.tar.gz
Let’s break this command down so we can understand what going on.

  • -z – This tells tar that we want to us gzip compression.
  • -c – This tells tar we want to create a new archive.
  • -v – This tell tar to tell us what it is doing.
  • -f – This tells tar what what file we want created.

Extracting a tarball

After you move the tarball you created earlier to the new server you would want to run the following command to extract it.

$ tar -zxvf website-backup.tar.gz

This command is much like the last one we ran other than instead of a -c we used an -x. This tells tar to extract the archive instead of creating and archive.
After running this command we will end up with a folder in our current working directory named var if we were to follow the directory structure it would looks like var/www/html/. Now you can move the files you extracted into their new home with something like.

$ mv var/www/html/* /var/www/html/

The post Using tar to backup and move your website appeared first on Bitbandits blog.

]]>