SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2010-12-08 03:07:15

aravinthrk
Member
Registered: 2010-02-03
Posts: 41

backup script to snapshot existing configs

Hopefully I'm not spamming..

With the new Statler images coming in, I guess many would like to install from ISO image. Good thing but what about the zillion customization done to the UI look and feel. And not to mention important stuff like Iceweasel profiles, Evolution data etc.,

Is there an application (hopefully there is...) to do the job? for now, I wrote a simple shell script and I intend to add to it everytime I do some customization. I invite people to add to the list on what else is needed according to them. Script to be run from home directory.

backupscript.sh
mkdir configbackup && cd configbackup

# Hidden directories backup

cp -r ../.config .
cp -r ../.gnome2 .
cp -r ../.mozilla .
cp -r ../.evolution .

## How to get the wine menu in lxpanel after copying this folder?
cp -r ../.wine .


# Regular directories backup
cp -r ../PDF .
cp -r ../htdocs .

# Files
cp ../.conkyrc .


My Rig: Thinkpad T60p (soon to be refreshed to Thinkpad W510), 2G DDR2, 100G HDD, Running @#! Statler A2 (squeeze) dual booting with Win 7. I use @#! for all purposes (MS Office for office work running in wine and Evolution with Exchange plugin for email)

Offline

Be excellent to each other!

#2 2010-12-08 05:44:05

anonymous
The Mystery Member
From: Arch Linux Forums
Registered: 2008-11-29
Posts: 8,899

Re: backup script to snapshot existing configs

I use a script as well though with full paths:

cp -avr /home/kevin/.config/awesome /media/Linux/Dropbox/Settings/Linux/home/kevin/.config
cp -avr /home/kevin/.config/clipit /media/Linux/Dropbox/Settings/Linux/home/kevin/.config
cp -avr /home/kevin/.config/geany /media/Linux/Dropbox/Settings/Linux/home/kevin/.config
cp -avr /home/kevin/.config/gnome-mplayer /media/Linux/Dropbox/Settings/Linux/home/kevin/.config

I do not know of a backup program that can backup settings just based on program name though. Usually people know what folders to backup or they backup their entire home folder.


Note: ** Please read before posting **

BTW if you wish to contact me, send me an e-mail instead of a PM.

Offline

#3 2010-12-08 14:25:47

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 7,419
Website

Re: backup script to snapshot existing configs

Curious why "cp"?

Compressed files are smaller:

tar cvpzf config_backup_`date +%Y.%m.%d-%R`.tgz
tar cvpzf home_backup_`date +%Y.%m.%d-%R`.tgz
tar cvpzf root_backup_`date +%Y.%m.%d-%R`.tgz

Offline

#4 2010-12-08 14:33:59

anonymous
The Mystery Member
From: Arch Linux Forums
Registered: 2008-11-29
Posts: 8,899

Re: backup script to snapshot existing configs

I just use cp because I'm copying individual files/folders. I also have a script to restore back the files using cp.


Note: ** Please read before posting **

BTW if you wish to contact me, send me an e-mail instead of a PM.

Offline

#5 2010-12-08 16:13:02

aravinthrk
Member
Registered: 2010-02-03
Posts: 41

Re: backup script to snapshot existing configs

@Sector11,

  guess each man chooses his own poison smile

  but here, the idea is not to take regular backups like you do using a timestamp in the file name. Its a evolving process where I keep adding stuff to the checklist so I'm not caught with my proverbial pants down when I have to shift images/system. Incidentally, I'm awaiting my new W510 and I seriously don't want to spend hours reconfiguring look & feel (it takes hours for me due to the indecision bug). After a lifetime of trying zillion UI changes, I've settled on all fronts and look to actually do some production smile

@anonymous,
just thinking aloud if something can be done about this? like a dropbox?

[edit]
on second thought, a windoze style 'send to -> backup bin' context menu option?

Last edited by aravinthrk (2010-12-08 16:23:09)


My Rig: Thinkpad T60p (soon to be refreshed to Thinkpad W510), 2G DDR2, 100G HDD, Running @#! Statler A2 (squeeze) dual booting with Win 7. I use @#! for all purposes (MS Office for office work running in wine and Evolution with Exchange plugin for email)

Offline

#6 2010-12-08 17:41:12

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 7,419
Website

Re: backup script to snapshot existing configs

Actually I use both methods, "cp" and "tar"

I've gone from:

#!/bin/bash
cp -R --update --preserve "/home/sector11/.claws-mail" "/media/7/home-bkup"
cp -R --update --preserve "/home/sector11/.mozilla" "/media/7/home-bkup"

to this:

#!/bin/bash
# inspired by aravinthrk & anonymous
# http://crunchbanglinux.org/forums/topic/10436/backup-script-to-snapshot-existing-configs/

mkdir /media/7/cb10-home_copy/`date +%Y.%m.%d`

# Hidden Directories
cp -avru "/home/sector11/.claws-mail" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
cp -avru "/home/sector11/.config" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
cp -avru "/home/sector11/.fontconfig" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
cp -avru "/home/sector11/.dropbox" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
cp -avru "/home/sector11/.dropbox-dist" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
cp -avru "/home/sector11/.fonts" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
cp -avru "/home/sector11/.gftp" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
cp -avru "/home/sector11/.homebank" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
cp -avru "/home/sector11/.icedove" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
cp -avru "/home/sector11/.icons" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
cp -avru "/home/sector11/.jpilot" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
cp -avru "/home/sector11/.mozilla" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
cp -avru "/home/sector11/.themes" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
cp -avru "/home/sector11/.when" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"

# Visible Directories
cp -avru "/home/sector11/bin" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
cp -avru "/home/sector11/Conky" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
cp -avru "/home/sector11/Conky_PitStop" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
cp -avru "/home/sector11/HomeBank" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
cp -avru "/home/sector11/images" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
cp -avru "/home/sector11/Mail" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
cp -avru "/home/sector11/projects" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
cp -avru "/home/sector11/Websites" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"

# Files
cp -avru "/home/sector11/.bashrc" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
cp -avru "/home/sector11/.clawsmail" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
cp -avru "/home/sector11/.conkyForecast.config" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
cp -avru "/home/sector11/.Xauthority" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
cp -avru "/home/sector11/.Xdefaults" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"

just from reading this thread.
Now I have to figure a way to so something like this:

===========
if exist: /media/7/cb10-home_copy/`date +%Y.%m.%d`
cp cpmmands
else
mkdir /media/7/cb10-home_copy/`date +%Y.%m.%d`
cp commands

so the -u function works if I "need" to make a second backup on the same day.

Gotta check the bash manual on that one  big_smile

I keep a few copies around ... just in case! Saved my bacon more than once because of that too!

PS: @ anonymous: 18 hours and running  big_smile

Offline

#7 2010-12-08 20:50:16

luc
#! Die Hard
From: Munich, Germany
Registered: 2010-03-21
Posts: 561

Re: backup script to snapshot existing configs

@ sector11

#!/bin/bash
if [ -d /some/dir/path ] ; then
  echo "It exists."
else
  echo "It doesn't exist."
fi

i know about these:

  • "-d" true if directory exists

  • "-r" true if file is readable

  • "-x" true if file is executable

  • "-f" true if file is a regular file

you can find them all in the manpage for bash if you look for the section "CONDITIONAL EXPRESSIONS"

cheers
luc

Offline

#8 2010-12-08 21:49:30

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 7,419
Website

Re: backup script to snapshot existing configs

luc wrote:

@ sector11

#!/bin/bash
if [ -d /some/dir/path ] ; then
  echo "It exists."
else
  echo "It doesn't exist."
fi

i know about these:

  • "-d" true if directory exists

  • "-r" true if file is readable

  • "-x" true if file is executable

  • "-f" true if file is a regular file

you can find them all in the manpage for bash if you look for the section "CONDITIONAL EXPRESSIONS"

cheers
luc

Thanks luc

I went looking (http://ss64.com/bash/) and found no "if, then else" stuff I did get this far though:

cd /media/7/cb10-home_copy/`date +%Y.%m.%d` || mkdir /media/7/cb10-home_copy/`date +%Y.%m.%d`

from the man pages, but had to do some "real life" things ... but it comes with a ton of what looks like "oh oh, that's not right!" stuff if the directory exists  smile

I'll play more now.  Thanks.

Offline

#9 2010-12-09 01:26:00

aravinthrk
Member
Registered: 2010-02-03
Posts: 41

Re: backup script to snapshot existing configs

Sector11,

   i recall seeing a bash guide book advertised in distrowatch.com free book listing... check it out. and yes, bash has a right proper if else construct... check our very own 'cb-welcome' script for reference smile that man has written some mean script over there.


My Rig: Thinkpad T60p (soon to be refreshed to Thinkpad W510), 2G DDR2, 100G HDD, Running @#! Statler A2 (squeeze) dual booting with Win 7. I use @#! for all purposes (MS Office for office work running in wine and Evolution with Exchange plugin for email)

Offline

#10 2010-12-09 13:35:13

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 7,419
Website

Re: backup script to snapshot existing configs

aravinthrk wrote:

Sector11,

   i recall seeing a bash guide book advertised in distrowatch.com free book listing... check it out. and yes, bash has a right proper if else construct... check our very own 'cb-welcome' script for reference smile that man has written some mean script over there.

Yea, I've seen it at DistroWatch but when it came to this:

Complete and verifiable information is required in order to receive this Guide.

First Name:     
Last Name:     
Job Title:     
Company Name:     
Business Email:     
Phone:     
Fax:     
Division/Mail Stop:     
Street Address:     
City:     
State/Province:     Alabama Alaska Arizona Arkansas California Colorado Connecticut Delaware District of Columbia Florida Georgia Hawaii Idaho Illinois Indiana Iowa Kansas Kentucky Louisiana Maine Maryland Massachusetts Michigan Minnesota Mississippi Missouri Montana Nebraska Nevada New Hampshire New Jersey New Mexico New York North Carolina North Dakota Ohio Oklahoma Oregon Pennsylvania Rhode Island South Carolina South Dakota Tennessee Texas Utah Vermont Virginia Washington West Virginia Wisconsin Wyoming American Samoa Guam Marshall Islands Micronesia (Federated States of) Palau Puerto Rico U.S. Minor Outlying Islands U.S. Virgin Islands Northern Mariana Islands Armed Forces Americas AA Armed Forces Middle East, Europe, Canada AE Armed Forces Pacific AP Alberta British Columbia Manitoba New Brunswick Newfoundland and Labrador Nova Scotia Northwest Territories Nunavut Ontario Prince Edward Island Quebec Saskatchewan Yukon Territory Aguascalientes Baja California Baja California Sur Campeche Chiapas Chihuahua Coahuila Colima Distrito Federal Durango Guanajuato Guerrero Hidalgo Jalisco Mexico State Michoacan Morelos Nayarit Nuevo Leon Oaxaca Puebla Queretaro Quintana Roo San Luis Potosi Sinaloa Sonora Tabasco Tamaulipas Tlaxcala Veracruz Yucatan Zacatecas

Postal/ZIP Code:     
Country:     

Yes, please auto-fill my contact information for other qualification forms.

... i backed down.  I don't live in any of those States/Provinces (or either Country for that matter)

Job Title:     no job
Company Name:   no company  
Business Email:     none
Phone:     none
Fax:     none
Division/Mail Stop:  none

Obviously they are not free for everyone.

I am collecting website links for Bash Scripting now.

BTW, your tip helped:

#!/bin/bash
#  -d file
#    True if file exists and is a directory.

if [ -d /media/7/cb10-home_copy/`date +%Y.%m.%d` ] ; then
  echo "It exists."
  # Hidden Directories
  cp -avru "/home/sector11/.claws-mail" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/.config" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/.fonts" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/.gftp" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/.icedove" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/.icons" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/.jpilot" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/.mozilla" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/.themes" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/.when" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"

  # Visible Directories
  cp -avru "/home/sector11/bin" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/Conky" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/conky" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/Conky_PitStop" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/HomeBank" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/images" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/Mail" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/projects" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/Websites" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"

  # Files
  cp -avru "/home/sector11/.bashrc" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/.conkyForecast.config" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/.Xauthority" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/.Xdefaults" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"

  echo "Home Directory now updated."
else
  echo "Directory doesn't exist - creating it."
  mkdir /media/7/cb10-home_copy/`date +%Y.%m.%d`
  # Hidden Directories
  cp -avru "/home/sector11/.claws-mail" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/.config" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/.fonts" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/.gftp" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/.icedove" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/.icons" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/.jpilot" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/.mozilla" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/.themes" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/.when" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"

  # Visible Directories
  cp -avru "/home/sector11/bin" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/Conky" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/conky" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/Conky_PitStop" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/HomeBank" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/images" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/Mail" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/projects" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/Websites" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"

  # Files
  cp -avru "/home/sector11/.bashrc" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/.conkyForecast.config" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/.Xauthority" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
  cp -avru "/home/sector11/.Xdefaults" "/media/7/cb10-home_copy/`date +%Y.%m.%d`"
fi
echo " "
echo "Done"

Did it once got everything, added a couple of images to ~/images and did it again. In seconds it was done and the new images were there.  Love that -u factor!

Thanks

Last edited by Sector11 (2010-12-09 13:40:41)

Offline

#11 2010-12-09 14:18:45

aravinthrk
Member
Registered: 2010-02-03
Posts: 41

Re: backup script to snapshot existing configs

^ I didn't have a problem downloading the book... not sure if it ok to share... otherwise I would... lemme know


My Rig: Thinkpad T60p (soon to be refreshed to Thinkpad W510), 2G DDR2, 100G HDD, Running @#! Statler A2 (squeeze) dual booting with Win 7. I use @#! for all purposes (MS Office for office work running in wine and Evolution with Exchange plugin for email)

Offline

#12 2010-12-09 14:30:21

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 7,419
Website

Re: backup script to snapshot existing configs

aravinthrk wrote:

^ I didn't have a problem downloading the book... not sure if it ok to share... otherwise I would... lemme know

Boy now that sounds like things done in my Windows days  smile

"Hey, Joe, can I get a copy of that?" lol lol
You have a PM !

Last edited by Sector11 (2010-12-09 14:31:16)

Offline

#13 2010-12-09 15:48:57

jmbarnes
#! Junkie
Registered: 2009-05-04
Posts: 250

Re: backup script to snapshot existing configs

@sector11 -- Like the idea.  I made a few changes so it's a bit shorter, and also is easy for others to use by just editing two variables at the top (Backup location and date format.) It also autodetects the user -- handy for multi-user systems.

#!/bin/bash
#  -d file
#    True if file exists and is a directory.
HOMECOPYPATH="/media/7/cb10-home_copy/"
CONFIGDATE="`date +%Y.%m.%d`"

if [ -d $HOMECOPYPATH/$CONFIGDATE ] ; then
  echo "It exists."
  else
      echo "Directory doesn't exist - creating it."
      mkdir $HOMECOPYPATH/$CONFIGDATE
fi

# Hidden Directories
cp -avru "/home/$USER/.claws-mail" "/media/7/cb10-home_copy/$CONFIGDATE"
cp -avru "/home/$USER/.config" "/media/7/cb10-home_copy/$CONFIGDATE"
cp -avru "/home/$USER/.fonts" "/media/7/cb10-home_copy/$CONFIGDATE"
cp -avru "/home/$USER/.gftp" "/media/7/cb10-home_copy/$CONFIGDATE"
cp -avru "/home/$USER/.icedove" "/media/7/cb10-home_copy/$CONFIGDATE"
cp -avru "/home/$USER/.icons" "/media/7/cb10-home_copy/$CONFIGDATE"
cp -avru "/home/$USER/.jpilot" "/media/7/cb10-home_copy/$CONFIGDATE"
cp -avru "/home/$USER/.mozilla" "/media/7/cb10-home_copy/$CONFIGDATE"
cp -avru "/home/$USER/.themes" "/media/7/cb10-home_copy/$CONFIGDATE"
cp -avru "/home/$USER/.when" "/media/7/cb10-home_copy/$CONFIGDATE"

# Visible Directories
cp -avru "/home/$USER/bin" "/media/7/cb10-home_copy/$CONFIGDATE"
cp -avru "/home/$USER/Conky" "/media/7/cb10-home_copy/$CONFIGDATE"
cp -avru "/home/$USER/conky" "/media/7/cb10-home_copy/$CONFIGDATE"
cp -avru "/home/$USER/Conky_PitStop" "/media/7/cb10-home_copy/$CONFIGDATE"
cp -avru "/home/$USER/HomeBank" "/media/7/cb10-home_copy/$CONFIGDATE"
cp -avru "/home/$USER/images" "/media/7/cb10-home_copy/$CONFIGDATE"
cp -avru "/home/$USER/Mail" "/media/7/cb10-home_copy/$CONFIGDATE"
cp -avru "/home/$USER/projects" "/media/7/cb10-home_copy/$CONFIGDATE"
cp -avru "/home/$USER/Websites" "/media/7/cb10-home_copy/$CONFIGDATE"

# Files
cp -avru "/home/$USER/.bashrc" "/media/7/cb10-home_copy/$CONFIGDATE"
cp -avru "/home/$USER/.conkyForecast.config" "/media/7/cb10-home_copy/$CONFIGDATE"
cp -avru "/home/$USER/.Xauthority" "/media/7/cb10-home_copy/$CONFIGDATE"
cp -avru "/home/$USER/.Xdefaults" "/media/7/cb10-home_copy/$CONFIGDATE"

echo "Home Directory now updated."
echo "Done"

IRC: PizzaAndWine     Script bits: Incremental Backup | Sleep Timer

Offline

#14 2010-12-09 15:52:20

aravinthrk
Member
Registered: 2010-02-03
Posts: 41

Re: backup script to snapshot existing configs

funny u shud remind me of windows.. i've forgotten the presence of the dual bootin win7 in my rig... more and more of my mates are getting impressed with what i'm able to do with linux... vive la OSS lol


My Rig: Thinkpad T60p (soon to be refreshed to Thinkpad W510), 2G DDR2, 100G HDD, Running @#! Statler A2 (squeeze) dual booting with Win 7. I use @#! for all purposes (MS Office for office work running in wine and Evolution with Exchange plugin for email)

Offline

#15 2010-12-09 15:53:37

anonymous
The Mystery Member
From: Arch Linux Forums
Registered: 2008-11-29
Posts: 8,899

Re: backup script to snapshot existing configs

Shouldn't you replace all the /media/7/cb10-home_copy/ with $HOMECOPYPATH?


Note: ** Please read before posting **

BTW if you wish to contact me, send me an e-mail instead of a PM.

Offline

#16 2010-12-09 16:11:24

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 7,419
Website

Re: backup script to snapshot existing configs

jmbarnes wrote:

@sector11 -- Like the idea.  I made a few changes so it's a bit shorter, and also is easy for others to use by just editing two variables at the top (Backup location and date format.) It also autodetects the user -- handy for multi-user systems.

WOW!!!!  Not only multi-user systems but by "anyone"!  Now that is good ... and a LOT shorther!

anonymous wrote:

Shouldn't you replace all the /media/7/cb10-home_copy/ with $HOMECOPYPATH?

I though something similar "Wonder why he didn't use it there?"
But sure looks good!

Offline

#17 2010-12-09 16:15:02

anonymous
The Mystery Member
From: Arch Linux Forums
Registered: 2008-11-29
Posts: 8,899

Re: backup script to snapshot existing configs

One more thing: I don't think the r flag is needed to copying files.


Note: ** Please read before posting **

BTW if you wish to contact me, send me an e-mail instead of a PM.

Offline

#18 2010-12-09 16:29:03

jmbarnes
#! Junkie
Registered: 2009-05-04
Posts: 250

Re: backup script to snapshot existing configs

anonymous wrote:

Shouldn't you replace all the /media/7/cb10-home_copy/ with $HOMECOPYPATH?

Yes...yes you should. My bad.


IRC: PizzaAndWine     Script bits: Incremental Backup | Sleep Timer

Offline

#19 2010-12-09 16:37:51

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 7,419
Website

Re: backup script to snapshot existing configs

anonymous wrote:

One more thing: I don't think the r flag is needed to copying files.

Yea, it not like there are sub-files!

hahahahahaha  - hey, I'm learning yesterday this green bean was planted and watered
... today I'm digging my way to sunlight!.

Or as vastOne once said::

VastOne wrote:

Baby step, baby steps!

Offline

#20 2010-12-09 16:53:04

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 7,419
Website

Re: backup script to snapshot existing configs

aravinthrk wrote:

funny u shud remind me of windows.. i've forgotten the presence of the dual bootin win7 in my rig... more and more of my mates are getting impressed with what i'm able to do with linux... vive la OSS lol

Hahahahahahaha ... I use Linux because Win2K gave me one to many "Bluescreen of Death" telling me my 6 month old 80GB WesterDigital HD was "DEAD".  Wouldn't even reinstall!

Ubuntu/Xubuntu used that drive for another 2 years before I went SATA, and a few weeks ago I dug it outta mothballs and installed it on mom-in-laws OLD Compaq running Slitaz Linux.

What I know compared to the people here would fit in on a thumbnail in mono font @ 8px, but I'm the family computer guru because I build my own and run Linux.  Go figure!

PLEASE don't tell them, I'm basking in the glory!  lol lol lol

Offline

#21 2010-12-09 16:58:59

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 7,419
Website

Re: backup script to snapshot existing configs

jmbarnes wrote:
anonymous wrote:

Shouldn't you replace all the /media/7/cb10-home_copy/ with $HOMECOPYPATH?

Yes...yes you should. My bad.

I took anonymous suggestion, my "???" and did it anyway.

#!/bin/bash
# inspired by mdpalow, aravinthrk, anonymous & jmbarnes
# http://crunchbanglinux.org/forums/topic/10436/backup-script-to-snapshot-existing-configs/

#  -d file
#    True if file exists and is a directory.

HOMECOPYPATH="/media/7/cb10-home_copy"
CONFIGDATE="`date +%Y.%m.%d`"

if [ -d $HOMECOPYPATH/$CONFIGDATE ] ; then
  echo "It exists."
  else
      echo "Directory doesn't exist - creating it."
      mkdir $HOMECOPYPATH/$CONFIGDATE
fi

# Hidden Directories
cp -avru "/home/$USER/.claws-mail" "$HOMECOPYPATH/$CONFIGDATE"
cp -avru "/home/$USER/.config" "$HOMECOPYPATH/$CONFIGDATE"
cp -avru "/home/$USER/.fonts" "$HOMECOPYPATH/$CONFIGDATE"
{snip}

and it works GREAT!
I've also looked at your two links in your sig ... smile

@ anonymous
And yes, the files section are no longer looking for sub-files  big_smile

Offline

#22 2010-12-09 17:39:54

luc
#! Die Hard
From: Munich, Germany
Registered: 2010-03-21
Posts: 561

Re: backup script to snapshot existing configs

What will be in the target directory if it exists? Will you overwrite important backup files there? If so I would recommend some different behavior if the dir exists. If it does not matter if we overwrite stuff in already existing directories you can use

mkdir -p path/to/newdir

to check and create the dir if it does not exist.
(read "man mkdir" for more info)

luc

Offline

#23 2010-12-09 18:16:02

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 7,419
Website

Re: backup script to snapshot existing configs

luc wrote:

What will be in the target directory if it exists? Will you overwrite important backup files there? If so I would recommend some different behavior if the dir exists. If it does not matter if we overwrite stuff in already existing directories you can use

mkdir -p path/to/newdir

to check and create the dir if it does not exist.
(read "man mkdir" for more info)

luc

If it doesn't exist it is created and the files copied.

If it does exist it's because the script has been run at least once today and if you have added NOTHING, or changed nothing - nothing happens-

cp
       -a, --archive
              same as -dR --preserve=all
       -d
              same as --no-dereference --preserve=links
       -u, --update
              copy  only  when  the  SOURCE file is newer than the destination
              file or when the destination file is missing
       -R, -r, --recursive
              copy directories recursively (probably not needed.  See -a)
       -v, --verbose
              explain what is being done

However if you add 6 images to ~/images and edit the calendar in ~/.when and run the script a second time on the same day, that -u kicks in, cp will NOT copy over files that are the same, it will add the six images and copy the updated calendar in ~/.when

Last edited by Sector11 (2010-12-09 18:18:41)

Offline

#24 2010-12-10 03:52:10

aravinthrk
Member
Registered: 2010-02-03
Posts: 41

Re: backup script to snapshot existing configs

Sector11 wrote:

Hahahahahahaha ... I use Linux because Win2K gave me one to many "Bluescreen of Death" telling me my 6 month old 80GB WesterDigital HD was "DEAD".  Wouldn't even reinstall!

Wow... w2k? that's like stone age man... refreshing though when one was using 95/98.
[edit] i had to add this... couldn't resist.... 'mv "refreshing though when one was using 95/98." "refreshing though when one was using 95/98 OR god forbid a commodore 64"' big_smile

Sector11 wrote:

What I know compared to the people here would fit in on a thumbnail in mono font @ 8px, but I'm the family computer guru because I build my own and run Linux.  Go figure!

PLEASE don't tell them, I'm basking in the glory!  lol lol lol

I won't.. if you won't big_smile yikes tongue

Last edited by aravinthrk (2010-12-10 04:05:18)


My Rig: Thinkpad T60p (soon to be refreshed to Thinkpad W510), 2G DDR2, 100G HDD, Running @#! Statler A2 (squeeze) dual booting with Win 7. I use @#! for all purposes (MS Office for office work running in wine and Evolution with Exchange plugin for email)

Offline

Help fund CrunchBang, donate to the project!

#25 2010-12-10 19:44:59

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 7,419
Website

Re: backup script to snapshot existing configs

aravinthrk wrote:

I won't.. if you won't big_smile yikes tongue

Hogan's Heros

Shultz: I see nothing, I hear nothing, I know nothing!  lol

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo