Hello there!
I need help:
I have this script:
#!/bin/bash
#chage to root user
sudo su
#Insert actual date
echo -n "Ingrese fecha actual: "
#Read the actual date
read fecha
#clean RAM memory
sync ; echo 3 > /proc/sys/vm/drop_caches ; swapoff -a && swapon -a
#backup opennms files
tar cvfzP opennms_etc_$fecha.tar.gz /etc/opennms/* -R
#copy PostgreSQL Client Authentication Configuration File
cp /etc/postgresql/8.3/main/pg_hba.conf pg_hba.conf
#copy PostgreSQL configurarion file
cp /etc/postgresql/8.3/main/postgresql.conf postgresql.conf
#change to postgres user
su - postgres
#backup PostgreSQL database
pg_dumpall > opennms_all_$fecha.sql
exit
#Move PostgreSQL database to the home directory
sudo mv opennms_all_$fecha.sql /home/bobbasystem
#Change to default user
su - bobbasystem
#copy all backuped files to main server
scp opennms_etc_$fecha.tar.gz trancos@172.17.40.232:
scp opennms_all_$fecha.sql trancos@172.17.40.232:
scp pg_hba.conf trancos@172.17.40.232:
scp postgresql.conf trancos@172.17.40.232:
#end
and when I change in the first line to root user, the script terminates without executing the rest.
If I delete these instructions and run the script with sudo su,
the instructions su -postgres can be executed, but not the rest.
How do I get the script does not end in these instructions?
Sorry for my english.
Thanks!