Creating a Terminal backup file

All Gurus once were Newbies
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. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read this

Creating a Terminal backup file

Postby axxess on Tue May 12, 2009 6:51 pm

Hey
I was just wondering... Can I create a txt file with Terminal commands in them, so I can open it with the Terminal to install apps and move stuff so if I need to backup, I could just put some commands to re-download my apps.
axxess
Level 1
Level 1
 
Posts: 12
Joined: Fri May 01, 2009 7:05 pm

Linux Mint is funded by ads and donations.
 

Re: Creating a Terminal backup file

Postby grimdestripador on Tue May 12, 2009 7:49 pm

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

User avatar
grimdestripador
Level 6
Level 6
 
Posts: 1069
Joined: Fri Feb 16, 2007 2:26 am

Re: Creating a Terminal backup file

Postby emorrp1 on Wed May 13, 2009 5:52 am

I believe there's a typo in grimdestripador's post, the first line of the script should be:
Code: Select all
#!/bin/sh
If you have a question that has been answered and solved, then please edit your original post and put a [SOLVED] at the end of your subject header
Hint - use a google search including the search term site:forums.linuxmint.com
emorrp1
Level 8
Level 8
 
Posts: 2322
Joined: Thu Feb 26, 2009 8:58 pm

Re: Creating a Terminal backup file

Postby grimdestripador on Tue May 19, 2009 9:58 pm

so true
User avatar
grimdestripador
Level 6
Level 6
 
Posts: 1069
Joined: Fri Feb 16, 2007 2:26 am


Return to Newbie Questions

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Google Adsense [Bot], LesStrater and 21 guests