[FoLUG] Fwd: [gentoo-gwn] Gentoo Weekly Newsletter - Volume 3,
Issue 28
Michele Mordenti
michele.mordenti@tin.it
Mar 13 Lug 2004 22:20:13 CEST
questa è troppo bella per tenerla per me,
come insegna Larry Wall c'è sempre più di un modo per fare una cosa.
---------- Messaggio inoltrato ----------
Subject: [gentoo-gwn] Gentoo Weekly Newsletter - Volume 3, Issue 28
Date: 15:58, martedì 13 luglio 2004
>From: Yuji Kosugi <indirizzo del tipo@gentoo.org>
To: gentoo-gwn@lists.gentoo.org
-----------------------------------------------------------------------
---- Gentoo Weekly Newsletter
http://www.gentoo.org/news/en/gwn/current.xml
This is the Gentoo Weekly Newsletter for the week of July 12th, 2004.
-----------------------------------------------------------------------
----
>...
>CUT
>...
==================
7. Tips and Tricks
==================
Using 'make' for backups
------------------------
Thanks to Lars Weiler[37] for providing this week's tip.
>37. { indirizzo del tipo@gentoo.org}
Usualy make from sys-devel/make is known as a tool for compiling
applications. But it could also be used to provide often used commands
so that they can be accessed easily.
Quite everybody wants to do backups. This could be done by packing them
with tar. For instance, we want to pack the ~/Mail folder and name the
file with a date:
-----------------------------------------------------------------------
----
| Code Listing 7.1:
| | tar ~/Mail with date included
| |
-----------------------------------------------------------------------
----
|$ tar cvjf ~/Backups/Mail-`date +%F`.tar.bz2 ~/Mail
| |
-----------------------------------------------------------------------
----
After that we copy that file (and possibly more) to another computer by
using rsync and delete all the files in ~/Backups afterwards:
-----------------------------------------------------------------------
----
| Code Listing 7.2:
| | Copy backup-file to another computer with rsync
| |
-----------------------------------------------------------------------
----
|$ rsync -avute ssh ~/Backups/ user@othermachine:~/Backups/
| | % rm ~/Backups/*
| |
-----------------------------------------------------------------------
----
And now comes the clue with make. After a week you already forgot the
commands. Why not store them in a Makefile located in the
home-directory, so that you only have to call make backup?
Inside the Makefile (beware of the uppercased 'M') we provide two
targets for the commands, so that we can call them separately, e.g. if
you only want to copy the files. The first target backup will only
call the other targets in the given order:
-----------------------------------------------------------------------
----
| Code Listing 7.3:
| | Sample Makefile for backups
| |
-----------------------------------------------------------------------
----
|backup: compress \
| | copy
| |
|
|compress:
| | tar cvjf ~/Backups/Mail-`date +%F`.tar.bz2 ~/Mail
| |
|
|copy:
| | rsync -avute ssh ~/Backups/ user@othermachine:~/Backups/
| | rm ~/Backups/*
| |
-----------------------------------------------------------------------
----
Now we can call make backup in the home directory and the ~/Mail-folder
will be compressed and copied to the other computer. The
restore-command-set will be your homework ;-)
Of course, there is a wide use for batched processes with Makefiles.
Think about all the things you ever wanted to have scripted with easy
usability. You can find more instructions in the info make pages.
> ...
> CUT
> ...
===================
12. Other Languages
===================
The Gentoo Weekly Newsletter is also available in the following
languages:
...
* Italian[46]
...
46. http://www.gentoo.org/news/it/gwn/gwn.xml
> ...
> CUT
> ...
-------------------------------------------------------
Per chi mastica poco l'inglese fra un po' di giorni uscirà la versione
tradotta in italiano, controllate il link [46].
--
Michele Mordenti - http://xoomer.virgilio.it/michele.mordenti
Powered by Gentoo GNU/Linux on DELL Inspiron 8500
Linux User:278480 - ICQ#:26479319 - JabberID:monstermord@jabber.org
Membro del FoLUG (Forli' Linux Users Group) - http://www.folug.org
Maggiori informazioni sulla lista
FoLUG