0

I have a CentOS 7 server, no desktop gui. It's used for inbound/outbound VOIP call recording, my plan is to copy today's recordings to my Google Drive. I have seen multiple Google Drive Linux compatible applications, haven't used any except g-drive a while back on a test server. all my recordings are saved in /home/recordings

I need a script to automatically create a new folder (with today's date like 25-02-2019) on Google Drive (in a specific folder located in my Google Drive account named "myrecordings"). after creating the folder, I need to copy all the recordings *.wav files from /home/recordings to googledrive/myrecordings/(today's date folder name)

thx in advance

  • What have you tried so far? – Fiximan Nov 8 at 12:15
  • I didn't try anything, not sure what to try. I do know how to create a folder in Linux with today's date like this mkdir # date +"%d-%m-%Y" – user381071 Nov 8 at 15:10
  • oh and I know how to copy files from local Linux to G-Drive, however I'm not sure how I can create that folder by date on the Google Drive, if even possible, and of course put this all in a script so I can do a cronjob to run it automatically – user381071 Nov 8 at 15:15
  • OK that is a good basis then. A few keywords to help you: write a script, stating with a shebang, that 1) opens the GDrive 2) creates the directory and 3) moves the files 4) closes connection to GDrive. Check for successful termination of 1,2,&3 before going to the next command using logical operators like &&. Try the script manually before going to a cronjob. ----- It's considered good practice here, to at least have a basic try and then let's see, where you are stuck. Update your question with your script by editing. – Fiximan Nov 8 at 16:10
  • Thank you @Fiximan but what you're telling me to do is exactly what I've requested help with, just re-wording it differently. Still looking for help as per the details I provided. – user381071 Nov 8 at 19:19
0
#!/bin/bash
today=`date +"%d-%m-%Y"`
destdir=/MOUNTPOINT_GOOGLEDRIVE/myrecordings/

mkdir $destdir/$today
mv /home/recordings/*.wav $destdir/$today

Change /MOUNTPOINT_GOOGLEDRIVE by the directory where your google drive is mounted.

EDIT:

If the google drive is not automatically mounted, add the command(s) you use to mount it. These depend on software you use.

  • thank you my friend. i used rclone as it was the most stable one i tested in the last couple days. without mounting my google drive, i set the script to create the date folder locally, then used the rclone copy function to send it to google drive, of course with the help of your script automated it – user381071 Nov 10 at 6:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.