Re: [PBML] compression and ftping a folder?
- 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 thisProbably a shell script would be easier.
> to occur daily!
> 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#!/bin/sh
tar -c $folder |bzip2 -9 >/tmp/TB$date.tar.bz2
> 3) "TheoBackup.pl" then opens an ftp connection to my ftp accountI 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 inUse the date.
> that ftp address.
> like 1.gzip, 2.gzip, 3.gzip
> 5) If there are more than X items in that ftp directory, it clears thecount="`ssh user@host 'ls \"remote_folder\" |wc -l'`"
> lowest ones.
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.