Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
hello people i am in need of linux help. iam at college and i need this back/restore script to pass this final part of an assessment. i require a backup script that will not only backup but also restore files to the relevent directories. e.g. users are instructed to store all wordprocessor files in a directory named wp. so i am needing to create a backup directory and 3 directories within that and some files within the 3 directories and then back them up ot restore them. l know i should/have to do this myself by been trying to get/understand info for the last few days and came up with zero. so i am pleading with some one out there for help.
thank you
hello people i am in need of linux help. iam at college and i need this back/restore script to pass this final part of an assessment. i require a backup script that will not only backup but also restore files to the relevent directories. e.g. users are instructed to store all wordprocessor files in a directory named wp. so i am needing to create a backup directory and 3 directories within that and some files within the 3 directories and then back them up ot restore them. l know i should/have to do this myself by been trying to get/understand info for the last few days and came up with zero. so i am pleading with some one out there for help.
thank you
that is the problem i do not know what to write even after looking at all the sites and books, the only thing i know how to do is the directories and files, and i will understand that i wont learn anything if people do the work for me but i genuinely do not know what to do. my lecturer just says problem solve it or fail but i cant problem solve it if i canr=t write and undertsand it. sorry for this but i do really need this.
thanks
sorry only ever used cp to copy files but should have added lecturer sowed a working example (but without showing the script). 1 backup 2. restore. 3. quit. he said something similar to that so onlyway i can describe it would be interactive, sorry if this confuses or makes the script harde for what i require but this is confusing me too.
marydoll, LQ doesn't respond well to "please help me, this is really hard for me" so you are unlikely to solve your problem with your current approach.
LQ is best at helping people to help themselves and to gain an understanding of Linux.
Your best tactic will be to try and recall what you learned on the course, check out some shell scripting introductions (plenty there if you netsearch or use LQ's search). A script is just a collection of commands in a file so you can experiment on the command line to familiarise yourself with the tools you need.
All computer languages are ways of communicating with a machine. Machines have no imagination so need to be told exactly what to do. The only way you are going to be able to do that is if you can think very clearly about what you want the machine to do -- in terms of directories and files for this assignment.
Make a start. Tell what you have thought and show what you have tried, then LQ is likely to help; not before.
#!/bin/sh
# Backup - create either a full or incremental backup of a set of
# defined directories on the system. By default, the output
# file is saved in /tmp with a timestamped filename, compressed.
# Otherwise, specify an output device (another disk, a removable).
usageQuit()
{
cat << "EOF" >&2
Usage: $0 [-o output] [-i|-f] [-n]
-o lets you specify an alternative backup file/device
-i is an incremental or -f is a full backup, and -n prevents
updating the timestamp if an incremental backup is done.
EOF
exit 1
}
compress="bzip2" # change for your favorite compression app
inclist="/tmp/backup.inclist.$(date +%d%m%y)"
output="/tmp/backup.$(date +%d%m%y).bz2"
tsfile="$HOME/.backup.timestamp"
btype="incremental" # default to an incremental backup
noinc=0 # and an update of the timestamp
trap "/bin/rm -f $inclist" EXIT
while getopts "o:ifn" opt; do
case "$arg" in
o ) output="$OPTARG"; ;;
i ) btype="incremental"; ;;
f ) btype="full"; ;;
n ) noinc=1; ;;
? ) usageQuit ;;
esac
done
shift $(( $OPTIND - 1 ))
echo "Doing $btype backup, saving output to $output"
timestamp="$(date +'%m%d%I%M')"
if [ "$btype" = "incremental" ] ; then
if [ ! -f $tsfile ] ; then
echo "Error: can't do an incremental backup: no timestamp file" >&2
exit 1
fi
find $HOME -depth -type f -newer $tsfile -user ${USER:-LOGNAME} | \
pax -w -x tar | $compress > $output
failure="$?"
else
find $HOME -depth -type f -user ${USER:-LOGNAME} | \
pax -w -x tar | $compress > $output
failure="$?"
fi
if [ "$noinc" = "0" -a "$failure" = "0" ] ; then
touch -t $timestamp $tsfile
fi
exit 0
and that came back with errors
Quote:
Doing incremental backup, saving output to /tmp/backup.191209.bz21
Error: can't do an incremental backup: no timestamp file
and in class we only got handed out a book with basic examples similar to the "hello world" script that seems to be on all web site tutorials, i would love to do this myself but i do not understand it to do it. not from a programming background (never even knew how to switch on a pc until 3 years ago)
You may try rsync. There are also some other tools to sync-tree. I did some search for you and here is the wiki page of rsync. At the end of it, there is an example of how to use rsync to do backup.
Your teacher should be pointing you guys to this free ebook "Advanced Bash Scripting Guide" that pretty much can get you from bash zero to hero in one night if your technically savvy. We won't do your work for you as that would be cheating, we can help with a script that you create.
ran the script -n just goes to command prompt again (dont even know if its meant to do that)
ran it with -f and get sam message as before but different filename
Quote:
Doing incremental backup, saving output to /tmp/backup.191209.bz2
Error: can't do an incremental backup: no timestamp file
ran the script -n just goes to command prompt again (dont even know if its meant to do that)
ran it with -f and get sam message as before but different filename
If you don't know what the script is doing, don't use it.
Start from scratch, and use the things you know from class.
No teacher will believe you made the script.
You will not learn, when you just copy stuff from other people.
I agree repo. Bash is not hard if you just need to do basic tasks, with the guide book I gave a link for and a couple of hours the OP could definitely knock a script together....and get a sense of well earned pride
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.