BackUps from the terminal with a script in Bash Shell

On February 14th I am in Linux.com a publication of Simrat Pal Singh Khokhar, where it presents a script in Bash shell of his authorship, which allows us to make a BackUp in the format

.tar.bz2

of any directory that is in our system.

Although the script It is a bit old, since this was originally published on March 13, 2009, I find it supremely useful both in its operation and in its ease of use.

To use the script, follow the following steps to the letter:

  1. Open a new document in Gedit or in dwarf as you prefer.
  2. Copy the full script code in this new document.
  3. Save the script as
    mybackup.sh

    in the place you want within your team (preferably in your personal folder).

Now we are going to give the script execution permissions through the following command (you must first locate yourself in the directory that contains the script):

chmod + x mybackup.sh

The way to use the script is as follows:

To perform the BackUp of a specific directory or file from doing so in the following way:

sh mybackup.sh [source] [destination]

Where source is the absolute path of the directory or file you want to backup (example:

~/Documentos/Writer

)
Where destination, is the path where you want to store the BackUp (example:

~/Documentos

)

Note: Simrat claims that the script recognizes both absolute and relative paths, but in my case only absolute paths worked.

This will result in the creation of a file

.tar.bz2

with the format

"fuente_ddmmyyyy.x.tar.bz2"

Now if you want to unzip a previous BackUp, you just have to run the script and specify the file

.tar.bz2

as source and the directory where you want to unzip the file as destination.

Additionally, this script can be used within Nautilus to make the BackUp in a much easier way.


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   thalskarth said

    Truth be told, I was just looking for something like that. I put it in CRON so that it is automatic every X time and that's it, I don't worry about the subject =)

  2.   John said

    The information is very good but you did not explain after all how to make the backup,
    1.Open a new document in Gedit or nano as you prefer.
    ►2.Copy the complete script code into this new document.
    3.Save the script as

    mybackup.sh

    yy! WHICH IS THE CODE? you helped me, in Nothing