Advertisement
czaru34

incrementalcopy

Jan 20th, 2020
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.94 KB | None | 0 0
  1. #!/bin/bash
  2. diskSpace=$(ssh root@192.168.21.101 df | grep /dev/sdb1 | awk '{print $4}')
  3. catalogSize=$(du -s /home/student | tail -1 | awk '{print $1}')
  4. while [ $diskSpace -lt $catalogSize ] ; do
  5.     archiveToDelete=$(ssh root@192.168.21.101 ls -lv /mnt/archiwum_lokalne | head -2 | awk 'NR==2{print $9}')
  6.     ssh root@192.168.21.101 rm -r /mnt/archiwum_lokalne/$archiveToDelete
  7.     diskSpace=$(ssh root@192.168.21.101 df | grep /dev/sdb1 | awk '{print $4}')
  8. done
  9.  
  10. date=$(date '+%Y_%m_%d_%H_%M_%S')
  11. fileName="archiwum_$date"
  12. archiveSource="/home/student/*"
  13. destination="/mnt/archiwum_lokalne"
  14. lastCopy=$(ssh root@192.168.21.101 ls -lv /mnt/archiwum_lokalne | tail -1 | awk '{print $9}')
  15.  
  16. mkdir $destination/$fileName
  17. rsync -avh --link-dest=root@192.168.21.101:/mnt/archiwum/ $archiveSource root@192.168.21.101:$destination/$fileName
  18. scp $destination/$fileName root@192.168.21.101:/mnt/archiwum_lokalne
  19. archiveName="$destination/$fileName"
  20. echo $archiveName
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement