LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Upgrade Slackware: using slackbuilds as a backup option (http://www.linuxquestions.org/questions/slackware-14/upgrade-slackware-using-slackbuilds-as-a-backup-option-4175484088/)

mlpa 11-10-2013 05:44 AM

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.

neymac 11-10-2013 06:52 AM

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.

mlpa 11-10-2013 06:56 AM

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".

neymac 11-10-2013 07:03 AM

Quote:

Originally Posted by mlpa (Post 5061834)
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).

mlpa 11-10-2013 07:08 AM

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.

neymac 11-10-2013 07:18 AM

Quote:

Originally Posted by mlpa (Post 5061840)
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


mlpa 11-10-2013 07:20 AM

Quote:

Originally Posted by neymac (Post 5061845)
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.

neymac 11-10-2013 07:25 AM

Quote:

Originally Posted by mlpa (Post 5061840)
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.

mlpa 11-10-2013 07:27 AM

Quote:

Originally Posted by neymac (Post 5061854)
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.

GazL 11-10-2013 09:03 AM

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.

mlpa 11-10-2013 10:20 AM

Quote:

Originally Posted by GazL (Post 5061905)
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 :)


All times are GMT -5. The time now is 02:28 PM.