Advertisement
czaru34

fullcopy

Jan 20th, 2020
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.74 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.  
  15. mkdir $destination/$fileName
  16. rsync -a $archiveSource root@192.168.21.101:$destination/$fileName
  17. archiveName="$destination/$fileName"
  18. echo $archiveName
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement