Find the answer to your Linux question:
Results 1 to 3 of 3
Im pretty new to linux and shell scripting and im trying to learn it Im trying to make a script that makes a backup of my home folder into /tmp/backup ...
  1. #1
    Just Joined!
    Join Date
    Dec 2011
    Posts
    5

    little help with my backup script please

    Im pretty new to linux and shell scripting and im trying to learn it
    Im trying to make a script that makes a backup of my home folder into /tmp/backup (this part i can do)

    but also if the dir /tmp/back does not excist i want the script to create it

    this is what i have so far but i cant reall get it to work

    Code:
    BRONDIR=/home/draxor
    BESTEMMINGDIR=/home/tmp/backup
    FILENAAM=Backup-$(date +%-y%-m%-d)-$(date +%-T).bac
    tar --create --gzip --file=$BESTEMMINGDIR$FILENAAM $BRONDIR
    
    PATH=$/home/draxor/backup
    If [ -d $PATH];
    Then
    Cp backup.bac /home/draxor
    Else
    Mkdir $PATH
    Echo "backup folder wordt aangemaakt & bestanden worden gekopieerd"
    Cp backup.bac /home/draxor/ 
    Fi

  2. #2
    Linux Enthusiast scathefire's Avatar
    Join Date
    Jan 2010
    Location
    Western Kentucky
    Posts
    616
    I try like this.

    Code:
    dir = /path/to/folder
    if [ ! -d $dir ]; then
    mkdir $dir  # or whatever routine you want to call#
    fi
    The '!' (or bang as its called) means 'not'.

    And no "$" in the name of your path variable.
    linux user # 503963

  3. #3
    Just Joined!
    Join Date
    Dec 2011
    Posts
    5
    thanks ill give it a try

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...