Thursday, 3 November 2011

list folder

list folder

Hi all, i have a script to backup my db, the problem is that it backups with the data it was created in the name, the second part of the script is to restore data and thats where the problem begins, how can i solve this since the file name is diferent?

HTML Code:

now=$(date +"%m_%d_%Y")
#!/bin/bash

selection=
until [ "$selection" = "0" ]; do
    echo ""
    echo Manutencao de BD
    echo - - - -now=$(date +"%m_%d_%Y") - - - - - -
    echo Backup
    echo 1. Backup Diario
    echo 2. Backup Semanal
    echo 3. Backup Mensal
    echo - - - - - - - - - -
    echo Restauro
    echo 4. Restauro Diario
    echo 5. Restauro Semanal
    echo 6. Restauro Mensal
    echo - - - - - - - - - -
    echo 7. Sair
    echo ""
    echo -n "Escolha uma opcao: "
    read selection
    echo ""

        echo -n "Tem a certeza?(s/n) "
        read text
       
if [ $text="s" ] | [ $text="S" ]; then
       
    case $selection in
        1 ) /opt/PostgreSQL/8.4/bin/pg_dump --host localhost --port 5432 --username postgres --format tar --blobs --verbose --file "/home/oc/Desktop/Backup_OC/Backup Diario/Backup_oc_diario_$now" openclinica;;
       
        2 ) /opt/PostgreSQL/8.4/bin/pg_dump --host localhost --port 5432 --username postgres --format tar --blobs --verbose --file "/home/oc/Desktop/Backup_OC/Backup Semanal/Backup_oc_semanal_$now" openclinica;;

        3 ) /opt/PostgreSQL/8.4/bin/pg_dump --host localhost --port 5432 --username postgres --format tar --blobs --verbose --file "/home/oc/Desktop/Backup_OC/Backup Mensal/Backup_oc_mensal_$now" openclinica;;
       
        4 ) /opt/PostgreSQL/8.4/bin/pg_dump --host localhost --port 5432 --username postgres --format custom --blobs --verbose --file "/home/oc/Desktop/Backup_OC/Backup_oc_diario_$now" openclinica;;
       
        5 ) /opt/PostgreSQL/8.4/bin/pg_dump --host localhost --port 5432 --username postgres --format custom --blobs --verbose --file "/home/oc/Desktop/Backup_OC/Backup_oc_semanal_$now" openclinica;;

        6 ) /opt/PostgreSQL/8.4/bin/pg_dump --host localhost --port 5432 --username postgres --format custom --blobs --verbose --file "/home/oc/Desktop/Backup_OC/Backup_oc_mensal_$now" openclinica;;

        7 ) exit ;;
        * ) echo "Escolha uma das opções apresentadas no menu"
    esac

else
exit

fi

done

thanks in advance

No comments:

Post a Comment