Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- diskSpace=$(ssh root@192.168.21.101 df | grep /dev/sdb1 | awk '{print $4}')
- catalogSize=$(du -s /home/student | tail -1 | awk '{print $1}')
- while [ $diskSpace -lt $catalogSize ] ; do
- archiveToDelete=$(ssh root@192.168.21.101 ls -lv /mnt/archiwum_lokalne | head -2 | awk 'NR==2{print $9}')
- ssh root@192.168.21.101 rm -r /mnt/archiwum_lokalne/$archiveToDelete
- diskSpace=$(ssh root@192.168.21.101 df | grep /dev/sdb1 | awk '{print $4}')
- done
- date=$(date '+%Y_%m_%d_%H_%M_%S')
- fileName="archiwum_$date"
- archiveSource="/home/student/*"
- destination="/mnt/archiwum_lokalne"
- lastCopy=$(ssh root@192.168.21.101 ls -lv /mnt/archiwum_lokalne | tail -1 | awk '{print $9}')
- mkdir $destination/$fileName
- rsync -avh --link-dest=root@192.168.21.101:/mnt/archiwum/ $archiveSource root@192.168.21.101:$destination/$fileName
- scp $destination/$fileName root@192.168.21.101:/mnt/archiwum_lokalne
- archiveName="$destination/$fileName"
- echo $archiveName
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement