Writing a bash script

I work and have to save a file in three locations besides the main HD. Instead of having to save the same file for four times, I would like to automate the procedure through a linux bash script file in which the first saved file on the HD can be copied simultaneously to an external HDD and to two flash drives.

My PC has two HDs. Windows Vista is installed on one, and openSuse 11.1 is installed on the other one. Windows Vista appears on SATA 1 while openSuse 11.1 appears on SATA 2. When I wish to switch from one OS to the other I just enter directly into the BIOS setup utility to change the HD boot order leaving the Windows and the Linux installs untouched.

How can this be performed?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I would probably investigate one of two options. First, you are
presumably wanting to go both directions… Linux to windows and windows
to Linux. If that is the case then perhaps check out a neat little
product (open source, etc.) called iFolder. If you have a server setup
you can synchronize there and the client in windows will synchronize with
the server as will the client in Linux. I do’nt know how else you can
reliably write a great script in windows to synchronize to Linux and your
two flash drives.

The other option, and part of the previous option, is to use something
like ‘rsync’ to synchronize files to/from one directory to/from others.
This tool has been around forever and should let you setup a source are
and a destination so you could copy from your home directory to flashA,
flashB, and windows. This same option would work to flashA and flashB
without the windows if you were using iFolder to keep windows and Linux in
sync with your server.

Anyway, those are my first guesses… may work for you but perhaps you’re
after something else.

Good luck.

sfzab wrote:
> I work and have to save a file in three locations besides the main HD.
> Instead of having to save the same file for four times, I would like to
> automate the procedure through a linux bash script file in which the
> first saved file on the HD can be copied simultaneously to an external
> HDD and to two flash drives.
>
> My PC has two HDs. Windows Vista is installed on one, and openSuse 11.1
> is installed on the other one. Windows Vista appears on SATA 1 while
> openSuse 11.1 appears on SATA 2. When I wish to switch from one OS to
> the other I just enter directly into the BIOS setup utility to change
> the HD boot order leaving the Windows and the Linux installs untouched.
>
> How can this be performed?
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQIcBAEBAgAGBQJJ6OjVAAoJEF+XTK08PnB5ypoQAMM1ldcLhD1Q9QLnzzHd5K7i
ZASj5p3Kmn2API1kJOY1dnp45x+sOZ8mkmp7NYgux+1jie2vLP2TlwEbtrIKZuM+
hv+92+JJFJir7NHh38oqo04VN6WwJCqrZDAPU53R4AUks9KE4PR3pdAIB2JdcWfU
LPvUGkhO/FDRgtcdBxhKDt89bmMkiuGYcMffww+7KET/f2wZX4Z5qFnorWfNBHfd
GKyRTMlsmj2FUN27h0udbrPEnT4mkQrw/TTZBnnyPmtqpcWrITw4VjXLQ0Agqvcx
O8hON6lhlHx3pyT9YaumUboAFGcsz6I9fPl+Pc8tQocB63ja4Gx1wrJZQx2CMVqV
ZmL/lbV0woQw38webCPdQIJFlJC6yyTOuI1dZLF3Rkl+yALiKLDgJ0ylTx0/ntzu
6s9qIuFrSPNBleTEDX3BN8vkYyIw4OjFkD1Ye471D5+j2QidcUUmi+hI2FF5G0Fp
aRBv526jDJ+qEM6KSGhWX8Rn8lhvUVpJFfqe9lQf38GgUX0HKLs6WZbSxnvdtoAg
s+v0czAp0ERO/IOEVdpegz50kqjq7pvX4ACYpbvykQRPCoxOwRkX9+4o70XP4nr5
/L12LR+MQVN1Gix6tx6lPVPB1FIWxa/kyRAp3RimgyZ3nPuPCqIFWSCbibme8mY9
EvpS5W3iXIVmPPIE6DFS
=0fJJ
-----END PGP SIGNATURE-----

Look at the audit subsystem’s dispatcher feature (auditd.conf(5)). There might be a way you could use this feature.

For the second part of a script line similar to

rsync -av /home/user/project/a.file **/user storage device/project
**
where the required storage devices are

/dev/sde1 … that is… an external hard disk {Maxtor 3200}
/dev/sdc1 … …"…"… a USB flash drive … {usb 1}
/dev/sdd1 … …"…"… a USB flash drive … {usb 2} and
/dev/sda1 … …"…"… a Windows Vista hard disk

to which I want to backup simultaneously there the content of the first part on the above line in openSuse 11.1 instead of having to save the same “a.file” for four more times, I receive a series of error messages when I try to run the respective rsync commands.

rsync -av /home/user/project/a.file /media/Maxtor 3200/project

rsync: link_stat “/media/Maxtor” failed: No such file or directory (2)
rsync: change_dir#3 “/home/user/3200/project” failed: No such file or directory (2)
rsync error: errors selecting input/output files, dirs (code 3) at main.c(614) [receiver=3.0.4]
rsync: connection unexpectedly closed (99 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(632) [sender=3.0.4]

rsync -av /home/user/project/a.file /media/usb 1/project

rsync: link_stat “/media/usb” failed: No such file or directory (2)
rsync: change_dir#3 “/home/user/1” failed: No such file or directory (2)
rsync error: errors selecting input/output files, dirs (code 3) at main.c(614) [receiver=3.0.4]
rsync: connection unexpectedly closed (9 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(632) [sender=3.0.4]

rsync -av /home/user/project/a.file /media/usb 2/project

rsync: link_stat “/media/usb” failed: No such file or directory (2)
rsync: change_dir#3 “/home/user/2” failed: No such file or directory (2)
rsync error: errors selecting input/output files, dirs (code 3) at main.c(614) [receiver=3.0.4]
rsync: connection unexpectedly closed (9 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(632) [sender=3.0.4]

rsync -av /home/user/project/a.file /media/disk/user/project

rsync: link_stat “/media/disk/user/” failed: No such file or directory (2)
rsync: link_stat “/home/user/” failed: No such file or directory (2)
rsync: change_dir#3 “/home/user/project” failed: No such file or directory (2)
rsync error: errors selecting input/output files, dirs (code 3) at main.c(614) [receiver=3.0.4]
rsync: connection unexpectedly closed (9 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(632) [sender=3.0.4]

In the graphical user interface (GUI) I am able to access and open the filesystems on all of the storage devices. In the command line interface (CLI) however I do not know how to do it. The backup script that I have in mind is aimed at updating simultaneously four file copies that are all on a local machine after the main “a.file” has been saved. I am not considering any actions or operations from Windows to Linux, but rather performing the whole updating process in Linux to keep things easier.

I will appreciate your assistance on any missing rsync options or other programming aspects that might have been overlooked.