Ubuntu :: Bash Script - Run Different Rsync Cmds Based On Which Devices Are Mounted
Apr 2, 2010
having my data backed up properly, but it's also in different places (e.g. photos and music on separate flash drives), so I have a few rsync's that I can execute manually, drives are mounted. Unfortunately, it gets confusing very quickly, I'd like a simple bash script that goes something like this (this pseudo-code would be most like REXX):
pair.1 = (/dev/sdb1, /dev/mmcblkp01)
pair.2 = (/some/other/device, /yet/another/device)
for i = 1 to #pairs
[code]....
Seems simple enough, but I've never written a bash script and wouldn't know where to start.
My computer has three drives: one with windows7,one as a storage drive, and an ide drive. I have ubuntu 10.04 installed on a seperate partition on the storage drive (+swap partition).I have "/etc/fstab" automatically monut these drives on startup:
I have recently mounted my iPod Touch using ifuse, and it works with gtkpod and I'm very pleased about that! However, I'm interested in finding out how openSUSE recognises what devices are mounted? Because the device manager in the task bar doesn't recognise that it's mounted... Dolphin doesn't recognise it and neither does Amarok. Only gtkpod, which is good, but I want other applications to recognise it. Do I need to mount it in a specific location? Currently it's at /mnt/iPhone. Or do I need something in fstab (I'm just guessing here).
I have a few websites that travel along with me in my usb stick, and I want to have read and write permisions to files on my usb by other users (i.e.: www-data) actually they have 0700. I'm running maverick (linux mint Julia).
last 3 rounds of updates to my Lucid system produced various problems, though each a solution to the previous issue. So I decided to upgrade to natty, and get new problems. LOL.
SO, my USB mouse and keyboard no longer mount on boot. If I unplug the keyboard and mouse, then re-insert them, they work fine.
I'm using LVM-based partitioning. I can not mount one partition. Here is some information I can provide.
Untitled-1.png snapshot7.png snapshot8.png
This incident happened after I try to encrypt this partition and then an error message appears. If not mistaken, it contains an error number (I forget) and a warning which reads that can not remove the LABEL on the devices.
I have 3 disks in my PC which are partitioned equally as I use them for Raid 1.The first partition on every disk is a simple ext2 partition for booting. No Raid there. So I mount them as /boot and /boot2 and /boot3. So I can backup my /boot to the other boot directories. That worked for some month and this morning I just want to look if all directories have enough free space left. So I did a df -h and got this:
Code: Dateisystem Grove Benut Verf Ben% Eingehängt auf /dev/mapper/system-root 6,0G 301M 5,4G 6% / udev 1,5G 292K 1,5G 1% /dev /dev/sdb1 122M 29M 87M 25% /boot /dev/sdc1 38M 21M 16M 59% /boot2 ... /dev/sda1 122M 29M 87M 25% /boot As you can see /dev/sda1 and /dev/sdb1 are both mounted on /boot
Here is what mount says: Code: /dev/sdb1 on /boot type ext2 (ro,acl,user_xattr) /dev/sdc1 on /boot2 type ext2 (ro,acl,user_xattr) ... /dev/sda1 on /boot type ext2 (ro,acl,user_xattr)
This is no Problem for me as I could just remount it correctly, but I would like to know if this problem is known. I did not change anything by now and this PC is a server which is running 24/7, so I can deliver more debugging Information if someone is interested.
This is probably me looking but not seeing an option somewhere. I re-installed 10.10 over 10.04 by formatting the root partition but keeping the home partition the same, to save me a lot of work. (64 bit) However, now when I mount a CD, DVD or USB stick, they don't appear in Dophin's "Places" window. What have I missed please?
I have a sony x10mini and it is correctly seen in nautilus and shotwell. But nor in banshee 1.6 (testing and sid) nor in 1.9 (experimental) is mounted. Fact is that I know it works for sure in fedora and debian so I wonder if it a problem of some dependency missing, configuration or permissions. I use the testing distro by the way...
When booting opensuse 11.2 or 11.3 there is automatically created a folder in /media to mount my external usb drive (in /media/disk). The problem I have is that sometimes these folders are not automatically removed when I shut down. On the next time boot this device is mounted at /media/disk-1 or /media/disk-2 which throws off for instance Krusader or Amarok. Also the folders that are not removed seem to have really strong permissions such that I can't even browse into them in Krusader or Dolphin. I have to manually clean the /media folder as super user so that when I reboot, they are in /media/disk. Does anyone know how to ensure that opensuse removes the folder(s) upon shutdown?
Sometimes when I try to display the mounted device in linux it displays devices which are not currently mounted. I want to correct this this using script.
Is there any Linux software that allows accessing a pre-configured serial console via Browser using a java applet? I would like to access the serial management consoles of various hardware devices via browser.
I've got a bash script that uses rsync via SSH to back up data from a remote webserver. This script works fine when I run it myself but when it runs as a cron job I get the following error:
I'm writing a script to automate rsync backups which so far is working great. I prefer to send output to a text file instead of watching it fly by but the blank output is slightly boring? I would love to use a progress bar. Not for each file but for overall progress. Something like
syncing /home directory 50% [++++++++]
I already know it's way over my head and maybe bash isn't even the right tool for the job.
Writing a bash script and I need to check if a known HD partition is mounted or not. I do not think /etc/mtab is the place to check. Would /proc/mounts always work? To make it simple like this : cat /proc/mounts | grep /dev/sdb2
I have a Truecrypt-encrypted Windows [system] partition, that I want to be opened and mounted automatically (using a keyfile) when I log into Debian, since it is also encrypted and I don't want to type two passphrases. It think this could be done with LUKS. With TC I probably have to go with the CLI, but haven't figured it out yet. And I can't add a keyfile to the volume using the GUI. In order to mount the volume I have to tick the Mount partition using system encryption (preboot authentication) checkbox, or otherwise I get Incorrect password or no TrueCrypt volume found. And same when I try to add a keyfile.
This is the error, and line 59 is the second quoted above:
Code: Select all/home/electrolux/bin/ts.sh: line 59: [[: 059: value too great for base (error token is "059")
The script is run every minute, and this error only occurs at 12:59AM, or 00:59.
I presume the problem is either $NOW is being set to 059, or the testing is seeing 0059 as 059. I think the latter, because for the rest of midnight 'til 00:58 the script works. And with some Googling it seems that the leading 0 is making test treat the number as octal... is there a way to tell it it is decimal?
Perhaps this is just some poor time-testing code? Looking at it I don't think it will cope with set time period that crosses midnight..... there's probably just a command to do what I want, isn't there? I know I could have two different scripts cron'd for the different time periods, but it would be much more preferable to be just the one.
how to migrate my whole server to larger hard drives (i.e. I'd like to replace my four 1TB's with four 2TB's, for a new total of 4TB instead of 2TB)... I'll post the output from everything (relevant) that I can think of in code tags below.
I'd like to end up with much larger /home and /public partitions. When I first set up raid and then LVM it seemed like it wouldn't be too hard once this day arrived, but I've had little luck finding help online for upgrades and resizing versus simply rebuilding from a failure. Specifically, I figure I have to mirror the data over to the new drives one at a time, but I can't figure out how to build the raid partitions on the new disks in order to have more space (yet mirror with the old drive that has a smaller partition)... don't the raid partitions have to be the same size to mirror?
Ubuntu Server (karmic) 2.6.31-22-server #65-Ubuntu SMP; fully updated
I had hard drive = 2 partition, 1 being extended. I had two ubuntu instances+swap+fat on extended and XP on primary. I moved a partition = success. I create a new partition = success. I installed new ubuntu instance -> fail on restart->. I saw sector error on screen on restart. So, Grub has lost 1 existing ubuntu instance and could not create new entry for new ubuntu instance. Read on forum just boot from Live CD and execute some grub cmds from terminal?
I'm pretty new to bash scripting, but I really want to wrap my head around it.What I'm trying to do is: From directory "A": Go in to all subdirectories and rename all files within icrementally according to the directory name. SO:
Is it possible to create a text based menu layout in bash were it is possible to browse through. The menu list should look something like this:
---------------------------------------- user: root colour: blue number: 4 animal: dog ----------------------------------------
At the start the cursor should blink at the r from root so that text can be entered. When pressing the enter the cursor should go to the b from blue and so on. the imported thing is that all the text is visible also beyond the position from the cursor.
I'm trying to call a specific variable based on a user selection. For example:
Code: Select a file:
[1] foo.tar [2] bar.tar
Enter a selection: I have already coded each possible selection to have its own variable. If the user selects 2 I need to select $SELECTED_TAR2, or if they select 1 I need to select $SELECTED_TAR1 and then do something like this behind the scenes:
I'm writing a bash shell script that among various other things will traverse through a directory with hundreds of files and rename those who match a pattern found in a config file. It's expected that only about one in ten files will actually match, and those who don't, will simply just be ignored for this purpose.
This should for instance cause the file "dBase program file December 1987.prg" to be renamed "Clipper source code December 1987.prg", and conversely "C++ source August 1996.cpp" to be renamed "C source code August 1996.cpp" etc.A sample file such as "Random Data File.dat" should not be renamed here since it's not mentioned in the config file..What is the quickest, most elegant way to do this in bash?I am thinking of using bash's built-in regex matching combined with the /bin/rename utility, but don't quite know how to get started to catch this..I guess there are plenty ways of doing this in perl and elsewhere as well, but since this has to integrate into a pre-existing bash script, that's what I'm looking for.Anyone out there with a spare moment to offer a hint in the right direction?
I can set my EDITOR variable in my .bashrc to e.g. gedit, which is a nice graphical editor on ubuntu. But when I log in over PuTTY that editor will fail.What is the best way to detect if I'm logged in and can run a graphical editor, or not, and set EDITOR appropriately?
I have very little linux experience. And need some help with a bash script. I need to a script I can set cron to run to sort files out of a holding folder into final folders. It doesn't necessarily have to be bash, but I think it would be sufficient for this. File names are formatted as such when created: Dest-Date-Time-CID-Destination# I want the files to be moved from a all in one holding folder to a folder structure like this.
So the script will need to make directories based on information in the file name which is delimited by single dashes. Then move files from the holding folder to the newly created "sorted" folders.
Want to run some cmds on Marc Greis Tutorial but always gets an error msg- "can't find ns: no such command. How can I resolve it? Also do not know how to edit on the terminal Have to start afresh anytime I notice a mistake. How can I successfully run a file to get a result. Have not been able to reproduce the result in Marc Greis tutorials.