tmpfs_backup.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/bash
  2. ContainerName=Nextcloud
  3. Path="/mnt/bigpart/Docker_files/"$ContainerName
  4. time1=$(date +"%s")
  5. logfile=$Path/Nextcloud.log
  6. OLDBACKUP=`date -d "3 days ago" +"%Y%m%d"`
  7. TODAY=`date +"%Y%m%d"`
  8. cd $Path/root
  9. echo "Backup tmpfs, Restore tmpfs"
  10. #if grep -qs $Path'/root' /proc/mounts; then
  11. echo "Nextcloud tmpfs is mounted.">> $logfile
  12. echo "Nextcloud tmpfs is mounted. making a backup"
  13. cd $Path/root
  14. tar -c --use-compress-program=pigz -f $Path/$TODAY-Backup.tar.bz2 *
  15. time2=$(date +"%s")
  16. diff=$(($time2-$time1))
  17. echo "backup finished @ `date`" >> $logfile
  18. echo "$(($diff / 60)) minutes and $(($diff % 60)) seconds elapsed." >> $logfile
  19. # rm -R $Path/$OLDBACKUP-Backup.tar.bz2
  20. #else
  21. # echo "Nextcloud tmpfs is NOT MOUNTED.!!!!!!!" >> $logfile
  22. # echo "Nextcloud tmpfs is NOT MOUNTED.!!!!!!!"
  23. # #rm -r $Path/root
  24. # mkdir -p $Path/root
  25. # #mount -t tmpfs -o size=1024M tmpfs $Path/root >> $logfile
  26. # for i in "`ls -tr1 $Path/*bz2| tail -1`"
  27. # do
  28. # echo "recover and start from backup: ${i}"
  29. # # tar -x --use-compress-program=pigz -f ${i} --directory $Path/root
  30. # done
  31. # echo "Restore finished @ `date`" >> $logfile
  32. # echo "Nextcloud tmpfs shoud be made. resinked backup"
  33. #fi
  34. echo "-------------------------------------------------------------------------------------------------------------------------------------------------------" >> $logfile