SlackwareThis Forum is for the discussion of Slackware Linux.
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.
tar -c -v --bzip2 --file=$filename --files-from=/home/iNew_list --exclude="$seamonkey/places.sqlite" --exclude="$seamonkey/netpredictions.sqlite" ...
You aren't closing the quotes properly. I have added a couple to show you. You're also being careless with the = sign; sometimes you add it, sometimes you don't. A backup script shouldn't be this haphazard. It would be a lot tidier and more manageable, for starters, if you put your exclude patterns in a file instead, and used the --exclude-from switch.
Sorry, could you pls. give 1 example of which file listed by your output of "tar" is not supposed to be there thanks to one of the exclude-parameters?
Did some random checks and I could not find anything... (or I have misunderstood the question or did not search correctly...).
seamonkey places.sqlite and places.sqlite-wal, for starters.
I'm sorry, but you do not back your claim that this is a bad backup script. Therefore your answer is useless. Tell the OP what is wrong with the script if you think it can be done better.
Also, what's wrong with a script being "distribution neutral"?
My first thought while reading the script was why not use the find command to provide the correct list of files versus using a mix of find, sed, and then tar to massage the file list? If for some reason find cannot do the right thing all by itself, then a find/grep combination should be able to give tar just the list that it needs.
My second thought was that there is probably a difference between either or both of:
The versions of bash between Gentoo and Slackware.
To Pearlseattle, I don't see a backslash at the top of my script:
Code:
michael@caitlyn ~ $ head system/dBackup
#!/bin/sh
hostname="caitlyn"
if [ -d /home/michael/.Trash ]; then
rm -r /home/michael/.Trash
fi
if [ -d /home/amy/.Trash ]; then
rm -r /home/amy/.Trash
fi
michael@caitlyn ~ $
I keep an updated copy of a Gentoo installation on a thumb drive, just in case I ever have problems booting into Slackware. I've only had to use it once, when I wanted to resize a partition on my single installed hard drive, and couldn't use gparted from within Slackware because the drive was currently mounted. I update both Slackware and the Gentoo drive every Sunday. I just checked the current version of bash and tar on both systems. The tar version is exactly the same - 1.29. The bash version is NEWER on Slackware than it is on Gentoo:
Gentoo:
Code:
root@caitlyn:~# chroot /mnt/gentoo/
caitlyn / # bash --version
GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)
Slackware:
Code:
michael@caitlyn ~ $ bash --version
GNU bash, version 4.4.5(1)-release (x86_64-slackware-linux-gnu)
So I don't think it's a version difference problem.
You aren't closing the quotes properly. I have added a couple to show you. You're also being careless with the = sign; sometimes you add it, sometimes you don't. A backup script shouldn't be this haphazard. It would be a lot tidier and more manageable, for starters, if you put your exclude patterns in a file instead, and used the --exclude-from switch.
You are very right. I didn't even notice that my double quotes use was inconsistent. I relocated my exclude list to a file in the system directory called excludes.lst. I've implemented your --exclude-from solution. Tomorrow we'll see if it works as well as I expect it to. I think it will. It makes logical sense.
OK. I implemented the --excludes-from solution yesterday. Here are my results:
Code:
michael@caitlyn ~ $ cat system/dBackup
#!/bin/sh
hostname="caitlyn"
if [ -d /home/michael/.Trash ]; then
rm -r /home/michael/.Trash
fi
if [ -d /home/amy/.Trash ]; then
rm -r /home/amy/.Trash
fi
today=`date '+%Y%m%d'`
monthyear=`date '+%Y%m'`
seamonkey="/home/michael/.mozilla/seamonkey/ulz2b39j.default"
thunderbird="/home/michael/.thunderbird/9r1hh5rz.default/"
# Home section
filename=/backup/$hostname/$monthyear/$hostname-slackware-michael-$today.tar.bz2
find /home/michael -daystart -type f -mtime 1 > /home/iBackup_list
cat /home/iBackup_list | sed '/ache/ d' | sed '/mail/ d' | sed '/pan/ d' > /home/iNew_list
tar -c -v --bzip2 --file=$filename --files-from=/home/iNew_list --exclude-from=/home/michael/system/excludes.lst
#tar -c -v --bzip2 --file=$filename --files-from=/home/iNew_list --exclude="$seamonkey/places.sqlite --exclude $seamonkey/netpredictions.sqlite" --exclude="$thunderbird/global-messages-db.sqlite --exclude $seamonkey/places.sqlite-wal" --exclude="$seamonkey/cookies.sqlite" --exclude "$thunderbird/places.sqlite" --exclude="$thunderbird/places.sqlite-wal" --exclude="$seamonkey/webappsstore.sqlite" --exclude="/home/michael/.mythtv/*" --exclude="/home/michael/.local/*" --exclude="/home/michael/.xsession-errors" --exclude="/home/michael/.macromedia/*" --exclude="/home/michael/.viminfo" --exclude="/home/michael/.config/*" --exclude="/home/michael/.bash*" --exclude="/home/michael/.gstreamer*" --exclude="/home/michael/.dbus/*" --exclude="/home/michael/.freeciv/*" --exclude="/home/michael/.Skype/*" --exclude="/home/michael/.thumbnails/*"
filename=/backup/$hostname/$monthyear/$hostname-slackware-etc-$today.tar.bz2
find /etc -daystart -type f -mtime 1 > /home/iBackup_list
tar -c -v --bzip2 --file=$filename --files-from=/home/iBackup_list
rm /home/iNew_list
rm /home/iBackup_list
michael@caitlyn ~ $ cat system/excludes.lst
/home/michael/.mozilla/seamonkey/ulz2b39j.default/places.sqlite
/home/michael/.mozilla/seamonkey/ulz2b39j.default/netpredictions.sqlite
/home/michael/.thunderbird/9r1hh5rz.defaultglobal-messages-db.sqlite
/home/michael/.mozilla/seamonkey/ulz2b39j.default/places.sqlite-wal
/home/michael/.mozilla/seamonkey/ulz2b39j.default/cookies.sqlite
/home/michael/.thunderbird/9r1hh5rz.defaultplaces.sqlite
/home/michael/.thunderbird/9r1hh5rz.defaultplaces.sqlite-wal
/home/michael/.mozilla/seamonkey/ulz2b39j.default/webappsstore.sqlite
/home/michael/.mythtv/*
/home/michael/.local/*
/home/michael/.xsession-errors
/home/michael/.macromedia/*
/home/michael/.viminfo
/home/michael/.config/*
/home/michael/.bash*
/home/michael/.gstreamer*
/home/michael/.dbus/*
/home/michael/.freeciv/*
/home/michael/.Skype/*
/home/michael/.thumbnails/*"
I DID have to delete a few files from the backup archive c/home/michael/.mozilla/seamonkey/ulz2b39j.default/places.sqlite-walreated this morning, but it was far smaller than I was expecting. Among the files I manually deleted where ~/.local and ~/.config as well as /home/michael/.mozilla/seamonkey/ulz2b39j.default/places.sqlite and /home/michael/.mozilla/seamonkey/ulz2b39j.default/places.sqlite-wal. Can any of you see the reason why these files were still in the archive?
You have also some missing slashes "/" for thunderbird files and a double-quote at the end.
I corrected the thunderbird slashes and removed the " at the end of the .thumbnails line. The funny thing is that I didn't have to manually delete anything from the .thunderbird directory in the archive this morning...
I corrected the thunderbird slashes and removed the " at the end of the .thumbnails line. The funny thing is that I didn't have to manually delete anything from the .thunderbird directory in the archive this morning...
Notice, that lines from file are read verbatim. One of the frequent errors is leaving some extra whitespace after a file name, which is difficult to catch using text editors.
Last edited by Gerard Lally; 05-08-2017 at 02:29 PM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.