Creating a Terminal backup file

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
User avatar
grimdestripador
Level 6
Level 6
Posts: 1051
Joined: Fri Feb 16, 2007 2:26 am

Re: Creating a Terminal backup file

Post by grimdestripador »

Its called a script, you most likely want a #/bin/bash or #/bin/sh script.
The script is simple as a text file with the commands you type into the terminal just with one extra line at the beginning.

Scripts are pretty unforgiving if you type something wrong, so you must have everyting working perfectly, then copy paiste from terminal into your script.

Be sure it starts with

Code: Select all

#/bin/sh
One thing that I do, is when I get a command working I add it to my script doing something like the following: Notice that the >> command routes the output to the last line in your text file. So if you tell the computer to echo what you just typed, have that passed to the script, its a few steps simpler than copy and pasting as, just press the up arrow in the terminal to access the previous statement.

Create the text file, with the first line to make it a script

Code: Select all

echo #/bin/sh >> backupscript.sh
I will now use various examples to show what can be done

Code: Select all

 echo echo Starting execuitation of backupscript.sh, please launch with sudo privilages >> backupscript.sh
echo apt-get install -f amarok vlc opera xmms nvidia-glx-177 >> backupscript.sh

echo echo now fixing permissions of shared folders >>backupscript.sh
chmod 755 -R ~/shared >> backupscript.sh

echo echo displaying your IP and restoring your files from rsync backup >>backupscript.sh
echo rsync -avz zeus::desktop Desktop >>backupscript.sh

Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
emorrp1

Re: Creating a Terminal backup file

Post by emorrp1 »

I believe there's a typo in grimdestripador's post, the first line of the script should be:

Code: Select all

#!/bin/sh
User avatar
grimdestripador
Level 6
Level 6
Posts: 1051
Joined: Fri Feb 16, 2007 2:26 am

Re: Creating a Terminal backup file

Post by grimdestripador »

so true
Locked

Return to “Beginner Questions”