Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] compression and ftping a folder?

Expand Messages
  • Hans Ginzel
    ... Probably a shell script would be easier. ... vi /etc/cron.daily/TheoBackup.sh ... #!/bin/sh folder= $1 remote_folder= $2 date= `date +%Y%m%d` tar -c
    Message 1 of 3 , Jan 7, 2004
    • 0 Attachment
      On Wed, Dec 24, 2003 at 06:00:13PM +0000, Theodore H.Smith wrote:
      > I want my computer to automate backup for me. Probably, I'd like this
      > to occur daily!

      Probably a shell script would be easier.

      > 1) Everyday, cron executes a perl script "TheoBackup.pl".

      vi /etc/cron.daily/TheoBackup.sh

      > 2) "TheoBackup.pl" gzips a folder specified in it's code


      date="`date +%Y%m%d`"
      tar -c $folder |bzip2 -9 >/tmp/TB$date.tar.bz2

      > 3) "TheoBackup.pl" then opens an ftp connection to my ftp account
      > elsewhere

      I would prefare secure shell, scp in this case:

      scp /tmp/TB$date.tar.bz2 "user@host:$remote_folder/"
      # man ssh, read about password/-less secure conection

      > 4) uploads the gzip file with a name 1 bigger than the last name in
      > that ftp address.
      > like 1.gzip, 2.gzip, 3.gzip

      Use the date.

      > 5) If there are more than X items in that ftp directory, it clears the
      > lowest ones.

      count="`ssh user@host 'ls \"remote_folder\" |wc -l'`"
      if [ $count -gt $SOME_CONSTANT ]
      count=$[$count-$SOME_CONSTANT] # +-1
      ssh user@host "ls \"$remote_folder\" |head -$count |xargs rm -f --'

      with ssh you execute code on a remote machine with current
      stdin/stdout. I did not test the code.

      Best regards

      Hans Ginzel
    Your message has been successfully submitted and would be delivered to recipients shortly.