Shell Script for Backup Screwing the Network [on hold]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












few months ago i made a script to backup some stuff from a Server Computer into a NAS (Network Attached Storage)



The script was supposed to mount the NAS and move the files into it, until this point everything went fine



however, because i didn't had much time to make a more complex Script, i made 4 different folders to use as backup directory, and made duplicates of the script changing its destiny, then i used crontab to each week backup the data into one of those folders



The reason i did this way is because as i said before, i didnt had time to make a more complex script, so i couldn't spent much time studying how to check if the file was modified or not, then overwrite the modified files, etc... so, that way was much simpler, because i could just erase everything and then paste the new data inside, also wouldn't be a problem, because it would keep the latest backup for more 3 weeks at least until a new one "overwrites" it



So, until the part my script mounts the nas and delete/paste the data, everything is working fine, the problem is when umounting



I dont know what is happening, because if i use the command to umount manually, it works just fine, but inside the script, seems like it isnt umounting, i dont know why



because the script wont umount correctly, into the following week, when the next script in queue try to mount, it cant mount due to the fact the NAS is already mounted



Plus, everything MUST be done automatically, that means i cant mount/umount manually



Here is a sample of the script bellow:



#!/bin/bash

pwd="root_password_here$"

echo $pwd | sudo -S id

sudo mount -t cifs //192.168.1.40/Act_Backup/SERVIDOR/dia17 -o username=USUARIO,password=SENHA,rw,nounix,iocharset=utf8,file_mode=0644,dir_mode=0755 /var/local/mountpoint

sudo rm -Rf /var/local/mountpoint/Act
Etc...

sudo cp -R /var/samba/Act /var/local/mountpoint
Etc...

sudo umount /var/local/mountpoint


I took out a lot of lines of the script just to show an example of how it works



Plus, i know its "wrong" to use: "echo $pwd | sudo -S id"
However, i needed to do some commands as root, not only because this part of the script, but a few more things, otherwise, it would not work



I will rewrite the script in the future, but at that time, im gonna make something much more complex and gonna take my take to study better about shell script, but for now, i would like to know if there's an quick solution or workaround to this problem



Everytime when the script try to UMOUNT and the NAS is already mounted, everyone in the network cant connect anymore to the Server Computer. By this point, there is just two solutions: rebooting or umounting manually.



I can assure the umount is what's causing that because i deactivated the script for an entire month just to make sure what was going on, and in that month we didn't had any kind of problems, so last week i reactivated the script, at the friday the script started running, and now on the monday, everyone was with the problem to connect into the server computer



And just in case anyone asks what error do we get, it is the error: "the network path was not found"



One more thing, this problem just happen into computers running windows (the server is ubuntu 18.04, so we use samba to share files)










share|improve this question















put on hold as unclear what you're asking by Rui F Ribeiro, Jeff Schaller, RalfFriedl, thrig, Timothy Martin Nov 19 at 19:38


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.


















    up vote
    0
    down vote

    favorite












    few months ago i made a script to backup some stuff from a Server Computer into a NAS (Network Attached Storage)



    The script was supposed to mount the NAS and move the files into it, until this point everything went fine



    however, because i didn't had much time to make a more complex Script, i made 4 different folders to use as backup directory, and made duplicates of the script changing its destiny, then i used crontab to each week backup the data into one of those folders



    The reason i did this way is because as i said before, i didnt had time to make a more complex script, so i couldn't spent much time studying how to check if the file was modified or not, then overwrite the modified files, etc... so, that way was much simpler, because i could just erase everything and then paste the new data inside, also wouldn't be a problem, because it would keep the latest backup for more 3 weeks at least until a new one "overwrites" it



    So, until the part my script mounts the nas and delete/paste the data, everything is working fine, the problem is when umounting



    I dont know what is happening, because if i use the command to umount manually, it works just fine, but inside the script, seems like it isnt umounting, i dont know why



    because the script wont umount correctly, into the following week, when the next script in queue try to mount, it cant mount due to the fact the NAS is already mounted



    Plus, everything MUST be done automatically, that means i cant mount/umount manually



    Here is a sample of the script bellow:



    #!/bin/bash

    pwd="root_password_here$"

    echo $pwd | sudo -S id

    sudo mount -t cifs //192.168.1.40/Act_Backup/SERVIDOR/dia17 -o username=USUARIO,password=SENHA,rw,nounix,iocharset=utf8,file_mode=0644,dir_mode=0755 /var/local/mountpoint

    sudo rm -Rf /var/local/mountpoint/Act
    Etc...

    sudo cp -R /var/samba/Act /var/local/mountpoint
    Etc...

    sudo umount /var/local/mountpoint


    I took out a lot of lines of the script just to show an example of how it works



    Plus, i know its "wrong" to use: "echo $pwd | sudo -S id"
    However, i needed to do some commands as root, not only because this part of the script, but a few more things, otherwise, it would not work



    I will rewrite the script in the future, but at that time, im gonna make something much more complex and gonna take my take to study better about shell script, but for now, i would like to know if there's an quick solution or workaround to this problem



    Everytime when the script try to UMOUNT and the NAS is already mounted, everyone in the network cant connect anymore to the Server Computer. By this point, there is just two solutions: rebooting or umounting manually.



    I can assure the umount is what's causing that because i deactivated the script for an entire month just to make sure what was going on, and in that month we didn't had any kind of problems, so last week i reactivated the script, at the friday the script started running, and now on the monday, everyone was with the problem to connect into the server computer



    And just in case anyone asks what error do we get, it is the error: "the network path was not found"



    One more thing, this problem just happen into computers running windows (the server is ubuntu 18.04, so we use samba to share files)










    share|improve this question















    put on hold as unclear what you're asking by Rui F Ribeiro, Jeff Schaller, RalfFriedl, thrig, Timothy Martin Nov 19 at 19:38


    Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      few months ago i made a script to backup some stuff from a Server Computer into a NAS (Network Attached Storage)



      The script was supposed to mount the NAS and move the files into it, until this point everything went fine



      however, because i didn't had much time to make a more complex Script, i made 4 different folders to use as backup directory, and made duplicates of the script changing its destiny, then i used crontab to each week backup the data into one of those folders



      The reason i did this way is because as i said before, i didnt had time to make a more complex script, so i couldn't spent much time studying how to check if the file was modified or not, then overwrite the modified files, etc... so, that way was much simpler, because i could just erase everything and then paste the new data inside, also wouldn't be a problem, because it would keep the latest backup for more 3 weeks at least until a new one "overwrites" it



      So, until the part my script mounts the nas and delete/paste the data, everything is working fine, the problem is when umounting



      I dont know what is happening, because if i use the command to umount manually, it works just fine, but inside the script, seems like it isnt umounting, i dont know why



      because the script wont umount correctly, into the following week, when the next script in queue try to mount, it cant mount due to the fact the NAS is already mounted



      Plus, everything MUST be done automatically, that means i cant mount/umount manually



      Here is a sample of the script bellow:



      #!/bin/bash

      pwd="root_password_here$"

      echo $pwd | sudo -S id

      sudo mount -t cifs //192.168.1.40/Act_Backup/SERVIDOR/dia17 -o username=USUARIO,password=SENHA,rw,nounix,iocharset=utf8,file_mode=0644,dir_mode=0755 /var/local/mountpoint

      sudo rm -Rf /var/local/mountpoint/Act
      Etc...

      sudo cp -R /var/samba/Act /var/local/mountpoint
      Etc...

      sudo umount /var/local/mountpoint


      I took out a lot of lines of the script just to show an example of how it works



      Plus, i know its "wrong" to use: "echo $pwd | sudo -S id"
      However, i needed to do some commands as root, not only because this part of the script, but a few more things, otherwise, it would not work



      I will rewrite the script in the future, but at that time, im gonna make something much more complex and gonna take my take to study better about shell script, but for now, i would like to know if there's an quick solution or workaround to this problem



      Everytime when the script try to UMOUNT and the NAS is already mounted, everyone in the network cant connect anymore to the Server Computer. By this point, there is just two solutions: rebooting or umounting manually.



      I can assure the umount is what's causing that because i deactivated the script for an entire month just to make sure what was going on, and in that month we didn't had any kind of problems, so last week i reactivated the script, at the friday the script started running, and now on the monday, everyone was with the problem to connect into the server computer



      And just in case anyone asks what error do we get, it is the error: "the network path was not found"



      One more thing, this problem just happen into computers running windows (the server is ubuntu 18.04, so we use samba to share files)










      share|improve this question















      few months ago i made a script to backup some stuff from a Server Computer into a NAS (Network Attached Storage)



      The script was supposed to mount the NAS and move the files into it, until this point everything went fine



      however, because i didn't had much time to make a more complex Script, i made 4 different folders to use as backup directory, and made duplicates of the script changing its destiny, then i used crontab to each week backup the data into one of those folders



      The reason i did this way is because as i said before, i didnt had time to make a more complex script, so i couldn't spent much time studying how to check if the file was modified or not, then overwrite the modified files, etc... so, that way was much simpler, because i could just erase everything and then paste the new data inside, also wouldn't be a problem, because it would keep the latest backup for more 3 weeks at least until a new one "overwrites" it



      So, until the part my script mounts the nas and delete/paste the data, everything is working fine, the problem is when umounting



      I dont know what is happening, because if i use the command to umount manually, it works just fine, but inside the script, seems like it isnt umounting, i dont know why



      because the script wont umount correctly, into the following week, when the next script in queue try to mount, it cant mount due to the fact the NAS is already mounted



      Plus, everything MUST be done automatically, that means i cant mount/umount manually



      Here is a sample of the script bellow:



      #!/bin/bash

      pwd="root_password_here$"

      echo $pwd | sudo -S id

      sudo mount -t cifs //192.168.1.40/Act_Backup/SERVIDOR/dia17 -o username=USUARIO,password=SENHA,rw,nounix,iocharset=utf8,file_mode=0644,dir_mode=0755 /var/local/mountpoint

      sudo rm -Rf /var/local/mountpoint/Act
      Etc...

      sudo cp -R /var/samba/Act /var/local/mountpoint
      Etc...

      sudo umount /var/local/mountpoint


      I took out a lot of lines of the script just to show an example of how it works



      Plus, i know its "wrong" to use: "echo $pwd | sudo -S id"
      However, i needed to do some commands as root, not only because this part of the script, but a few more things, otherwise, it would not work



      I will rewrite the script in the future, but at that time, im gonna make something much more complex and gonna take my take to study better about shell script, but for now, i would like to know if there's an quick solution or workaround to this problem



      Everytime when the script try to UMOUNT and the NAS is already mounted, everyone in the network cant connect anymore to the Server Computer. By this point, there is just two solutions: rebooting or umounting manually.



      I can assure the umount is what's causing that because i deactivated the script for an entire month just to make sure what was going on, and in that month we didn't had any kind of problems, so last week i reactivated the script, at the friday the script started running, and now on the monday, everyone was with the problem to connect into the server computer



      And just in case anyone asks what error do we get, it is the error: "the network path was not found"



      One more thing, this problem just happen into computers running windows (the server is ubuntu 18.04, so we use samba to share files)







      shell-script unmounting






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 19 at 19:02









      Rui F Ribeiro

      38.2k1475125




      38.2k1475125










      asked Nov 19 at 16:29









      Kouhei

      11




      11




      put on hold as unclear what you're asking by Rui F Ribeiro, Jeff Schaller, RalfFriedl, thrig, Timothy Martin Nov 19 at 19:38


      Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






      put on hold as unclear what you're asking by Rui F Ribeiro, Jeff Schaller, RalfFriedl, thrig, Timothy Martin Nov 19 at 19:38


      Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.



























          active

          oldest

          votes






















          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes

          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay