LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 11-10-2013, 06:44 AM   #1
mlpa
Member
 
Registered: May 2008
Location: Aveiro
Distribution: Slackware
Posts: 503

Rep: Reputation: 38
Upgrade Slackware: using slackbuilds as a backup option


As many of you I am currently preparing to install a fresh new version of Slackware. A tedious part of installing a new OS is saving my configurations and important scripts.
In order to ease this process I write a slackbuild that stores my configurations. It is available here.

Test the script, add functions to store your important data, send feedback.
Is public available for the Slackware community.
 
Old 11-10-2013, 07:52 AM   #2
neymac
Member
 
Registered: May 2009
Distribution: Slackware64-14.0
Posts: 117

Rep: Reputation: 13
The use of the lines:
USER=${USER:-$(whoami)}
GROUP=${GROUP:-$(id -gn $USER)}
HOMEDIR=${HOMEDIR:-$(eval echo ~${USER})}
when using "su" to run the script return "root" as user (usuário root) and home of root as well instead of my user name and root, if you run without root it doesn't backup the root folder, and the script stops when it doesn't find the files called by one of the functions. But it's a good idea after some fixes.

Last edited by neymac; 11-10-2013 at 07:58 AM.
 
Old 11-10-2013, 07:56 AM   #3
mlpa
Member
 
Registered: May 2008
Location: Aveiro
Distribution: Slackware
Posts: 503

Original Poster
Rep: Reputation: 38
You can define the value of USER.
For example: USER=john; ./backup.Slackbuild
Or you can change that value on USER in the file itself: USER=${USER:-$(whoami)} becomes USER="john".
 
Old 11-10-2013, 08:03 AM   #4
neymac
Member
 
Registered: May 2009
Distribution: Slackware64-14.0
Posts: 117

Rep: Reputation: 13
Quote:
Originally Posted by mlpa View Post
You can define the value of USER.
For example: USER=john; ./backup.Slackbuild
Or you can change that value on USER in the file itself: USER=${USER:-$(whoami)} becomes USER="john".
Ok, it is a solution, but if you do so the configurations files at /root folder or those which belongs to root will not be backed up, and some changes must be done to avoid stop the script when it didn't find a file requested by the functions, a kind of test to see if the file exists or not (if [].. else).

Last edited by neymac; 11-10-2013 at 08:48 AM.
 
Old 11-10-2013, 08:08 AM   #5
mlpa
Member
 
Registered: May 2008
Location: Aveiro
Distribution: Slackware
Posts: 503

Original Poster
Rep: Reputation: 38
I never intended to save root configurations.
I do not have any configuration in the root account.
This works exactly like a slackbuild, and you may need to specify some variables.
You can comment any function that you do not want to use:
Quote:
backup_SSH
backup_NTP
backup_VIM
backup_BASH_RC
backup_RC_LOCAL
Or add more backup functions.
This works like a slackbuils, but it is a much more personal script.
I can not predict what each person wants to save.
I will for a way to not stop the scritp when a backup function fails.
 
Old 11-10-2013, 08:18 AM   #6
neymac
Member
 
Registered: May 2009
Distribution: Slackware64-14.0
Posts: 117

Rep: Reputation: 13
Quote:
Originally Posted by mlpa View Post
I never intended to save root configurations.
I do not have any configuration in the root account.
But I have some configurations at my /root ( I think that when I run vim, etc as root they are storage there) this is my /root:

Code:
bash-4.2$ cd /root
bash-4.2$ sudo ls -al
Password:
total 172
drwx--x--- 24 root root  4096 Nov  8 22:52 .
drwxr-xr-x 22 root root  4096 Nov  8 23:23 ..
drwx------  3 root root  4096 Ago 10 19:33 .adobe
-rw-------  1 root root 13954 Nov 10 10:39 .bash_history
-rw-r--r--  1 root root    55 Jun 28  2011 .bash_profile
-rw-r--r--  1 root root   224 Abr 13  2012 .bashrc
drwx------  3 root root  4096 Out 29 00:22 .cache
drwxr-xr-x 18 root root  4096 Out 19  2010 .ccache
drwxr-xr-x  7 root root  4096 Nov  8 10:54 .config
drwx------  3 root root  4096 Ago 27  2010 .dbus
drwxr-xr-x  4 root root  4096 Out 19  2010 .distcc
drwx------  3 root root  4096 Nov  2  2011 .fltk
drwx------  2 root root  4096 Ago 10 19:33 .gconf
drwx------  2 root root  4096 Nov  8 23:23 .gnupg
-rw-r--r--  1 root root 32256 Out  4  2010 good_mbr
drwxr-xr-x  2 root root  4096 Ago 19 02:26 .gstreamer-0.10
drwx------  2 root root  4096 Jun 15 16:45 .gvfs
drwxr-xr-x  3 root root  4096 Nov  3  2010 .jubler
drwx------  4 root root  4096 Jun 15 16:45 .kde
drwx------  2 root root  4096 Jun 14 14:32 .links
drwx------  3 root root  4096 Ago 29  2010 .local
drwx------  3 root root  4096 Ago 10 19:33 .macromedia
drwx------  4 root root  4096 Ago 10 19:33 .mozilla
drwxr-xr-x  2 root root  4096 Set  1  2010 News
-rw-r--r--  1 root root    31 Jun 14 15:48 .sbopkg.conf
drwxr-xr-x  3 root root  4096 Ago 28  2010 .subversion
drwxr-xr-x  2 root root  4096 Jun 14 16:30 .vim
-rw-------  1 root root  8412 Nov  8 22:52 .viminfo
drwxr-xr-x  2 root root  4096 Jun 15 16:45 .wicd
-rw-------  1 root root     0 Jun 15 16:46 .Xauthority
drwxr-xr-x  2 root root  4096 Ago 30  2010 .xine
-rw-r--r--  1 root root   534 Ago 26  2010 .xinitrc

Last edited by neymac; 11-10-2013 at 08:29 AM.
 
Old 11-10-2013, 08:20 AM   #7
mlpa
Member
 
Registered: May 2008
Location: Aveiro
Distribution: Slackware
Posts: 503

Original Poster
Rep: Reputation: 38
Quote:
Originally Posted by neymac View Post
But I have some configurations at my /root ( I think that when I run vim, etc as root they are storage there) htis is my /root:

Code:
bash-4.2$ cd /root
bash-4.2$ sudo ls -al
Password:
total 172
drwx--x--- 24 root root  4096 Nov  8 22:52 .
drwxr-xr-x 22 root root  4096 Nov  8 23:23 ..
drwx------  3 root root  4096 Ago 10 19:33 .adobe
-rw-------  1 root root 13954 Nov 10 10:39 .bash_history
-rw-r--r--  1 root root    55 Jun 28  2011 .bash_profile
-rw-r--r--  1 root root   224 Abr 13  2012 .bashrc
drwx------  3 root root  4096 Out 29 00:22 .cache
drwxr-xr-x 18 root root  4096 Out 19  2010 .ccache
drwxr-xr-x  7 root root  4096 Nov  8 10:54 .config
drwx------  3 root root  4096 Ago 27  2010 .dbus
drwxr-xr-x  4 root root  4096 Out 19  2010 .distcc
drwx------  3 root root  4096 Nov  2  2011 .fltk
drwx------  2 root root  4096 Ago 10 19:33 .gconf
drwx------  2 root root  4096 Nov  8 23:23 .gnupg
-rw-r--r--  1 root root 32256 Out  4  2010 good_mbr
drwxr-xr-x  2 root root  4096 Ago 19 02:26 .gstreamer-0.10
drwx------  2 root root  4096 Jun 15 16:45 .gvfs
drwxr-xr-x  3 root root  4096 Nov  3  2010 .jubler
drwx------  4 root root  4096 Jun 15 16:45 .kde
drwx------  2 root root  4096 Jun 14 14:32 .links
drwx------  3 root root  4096 Ago 29  2010 .local
drwx------  3 root root  4096 Ago 10 19:33 .macromedia
drwx------  4 root root  4096 Ago 10 19:33 .mozilla
drwxr-xr-x  2 root root  4096 Set  1  2010 News
-rw-r--r--  1 root root    31 Jun 14 15:48 .sbopkg.conf
drwxr-xr-x  3 root root  4096 Ago 28  2010 .subversion
drwxr-xr-x  2 root root  4096 Jun 14 16:30 .vim
-rw-------  1 root root  8412 Nov  8 22:52 .viminfo
drwxr-xr-x  2 root root  4096 Jun 15 16:45 .wicd
-rw-------  1 root root     0 Jun 15 16:46 .Xauthority
drwxr-xr-x  2 root root  4096 Ago 30  2010 .xine
-rw-r--r--  1 root root   534 Ago 26  2010 .xinitrc
You can add functions to store the root account.
Or run the script twice with two different users.
In my free time I will try to add that feature.
 
Old 11-10-2013, 08:25 AM   #8
neymac
Member
 
Registered: May 2009
Distribution: Slackware64-14.0
Posts: 117

Rep: Reputation: 13
Quote:
Originally Posted by mlpa View Post
I can not predict what each person wants to save.
I will for a way to not stop the scritp when a backup function fails.
As sugestion you could include a "ls | grep" command inside the script to check and grab the existent files and do some loops to back them up using less functions do do so, doing this you don't need to test if the files exists or not.
 
Old 11-10-2013, 08:27 AM   #9
mlpa
Member
 
Registered: May 2008
Location: Aveiro
Distribution: Slackware
Posts: 503

Original Poster
Rep: Reputation: 38
Quote:
Originally Posted by neymac View Post
As sugestion you could include a "ls | grep" command inside the script to check and grab the existent files and do some loops to back them up using less functions do do so, doing this you don't need to test if the files exists or not.
I want to keep a modular approach, a function for each important entity.
This way any person can add or remove backup functions.
This script will never be one size fits all, but a base for personalized backup scripts.
 
Old 11-10-2013, 10:03 AM   #10
GazL
Senior Member
 
Registered: May 2008
Posts: 3,502

Rep: Reputation: 1024Reputation: 1024Reputation: 1024Reputation: 1024Reputation: 1024Reputation: 1024Reputation: 1024Reputation: 1024
What I do is keep a file named /root/changed_files that I update with the absolute path of every config file, or script that I change or add, and also /root/ChangeLog in which I write notes to remind myself of what I've changed and why I changed it, along with any manual actions/commands that I need to take/run.

Then I just:
# tar -cvf my_changes.tar -C / -T /root/changed_files

The trick is to include both /root/changed_files and /root/ChangeLog in the list of files in /root/changed_files.

When you come to unpack it, The only thing you have to be careful of is not to clobber anything system specific which might be different, such as /etc/fstab or lilo.conf, but that's easy enough to protect against:

# tar -xvf my_changes.tar -C / root/changed_files
# tar -cvf backup_existing.tar --ignore-failed-read -C / -T /root/changed_files
# tar -xvf my_changes.tar -C /



Anyway, that's how I do it.

Last edited by GazL; 11-10-2013 at 10:12 AM.
 
2 members found this post helpful.
Old 11-10-2013, 11:20 AM   #11
mlpa
Member
 
Registered: May 2008
Location: Aveiro
Distribution: Slackware
Posts: 503

Original Poster
Rep: Reputation: 38
Quote:
Originally Posted by GazL View Post
What I do is keep a file named /root/changed_files that I update with the absolute path of every config file, or script that I change or add, and also /root/ChangeLog in which I write notes to remind myself of what I've changed and why I changed it, along with any manual actions/commands that I need to take/run.

Then I just:
# tar -cvf my_changes.tar -C / -T /root/changed_files

The trick is to include both /root/changed_files and /root/ChangeLog in the list of files in /root/changed_files.

When you come to unpack it, The only thing you have to be careful of is not to clobber anything system specific which might be different, such as /etc/fstab or lilo.conf, but that's easy enough to protect against:

# tar -xvf my_changes.tar -C / root/changed_files
# tar -cvf backup_existing.tar --ignore-failed-read -C / -T /root/changed_files
# tar -xvf my_changes.tar -C /



Anyway, that's how I do it.
It is an useful way to keep your backup.
My idea is to provide some type of automatic mechanism that is simpler enough to be used rapidly.
The result was a slackbuild that creates a backup.

Any other scripts designed for backup are more than welcome
 
  


Reply

Tags
backup, configurations, installpkg, script


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Slackbuilds for slackware 13.37 not working..... honeybadger Slackware 7 06-22-2012 02:54 PM
[SOLVED] Minor problem with SlackBuilds E17 upgrade for Edje linus72 Slackware 2 12-23-2011 09:11 PM
[SOLVED] Slackware 13 on slackbuilds hua Slackware 14 01-26-2010 02:13 PM
Webmin on Slackware -- w or w/o Slackbuilds GaHillBilly Slackware 1 10-27-2009 04:23 PM
LXer: Slackbuilds: A Slackware solution LXer Syndicated Linux News 0 09-13-2007 02:50 AM


All times are GMT -5. The time now is 04:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration