# Help with simple script copy multiple folder and exit code

**URL:** <https://forum.rclone.org/t/help-with-simple-script-copy-multiple-folder-and-exit-code/36716>\
**Category:** Help and Support\
**Created:** [March 12, 2023, 10:11am UTC](https://forum.rclone.org/t/help-with-simple-script-copy-multiple-folder-and-exit-code/36716 "2023-03-12T10:11:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ale82x](https://forum.rclone.org/user_avatar/forum.rclone.org/ale82x/32/1610_2.png) [@ale82x](https://forum.rclone.org/u/ale82x)\
**Post date:** [March 12, 2023, 10:11am UTC](https://forum.rclone.org/t/help-with-simple-script-copy-multiple-folder-and-exit-code/36716/1 "2023-03-12T10:11:36Z")

</div>

yes

#### Which cloud storage system are you using? (eg Google Drive)

google drive

#### The command you were trying to run (eg `rclone copy /tmp remote:tmp`)

```auto
rclone copy /share/folder1/ remote:/folder1/current --backup-dir remote:/folder1/`date +%Y-%m-%d__%H-%M-%S`/ -v --log-file=/var/log/rclone.log --bwlimit=2M

```

#### The rclone config contents with secrets removed.

```auto
[remote
type = drive
client_id = xxxxxxxxxxxxx
client_secret = xxxxxxxxxxxxxxx
scope = drive
service_account_file = /my/json.json
team_drive = xxxxxxxxxxxxx
root_folder_id = 
acknowledge_abuse = true
stop_on_upload_limit = true
stop_on_download_limit = true

```

#### A log from the command with the `-vv` flag

```auto
no error , so i can't copy log

```

with command posted before works great, i would insert in a script and with a single folder work great  
my script is

```auto
rclone copy /share/folder1/ remote:/folder1/current --backup-dir remote:/folder1/`date +%Y-%m-%d__%H-%M-%S`/ -v --log-file=/var/log/rclone.log --bwlimit=2M
wget --no-check-certificate https://hc-ping.com/<id>/$?
exit

```

so i copy my files from nas or linux and put exit code on [https://healthchecks.io](https://healthchecks.io)  
so i'm sure that "backup" that work with exit code 0

now i would extend this script for my friend on his NAS.  
he have more folder so i think script becomes

```auto
rclone copy /share/folder1/ remote:/folder1/current --backup-dir remote:/folder1/`date +%Y-%m-%d__%H-%M-%S`/ -v --log-file=/var/log/rclone.log --bwlimit=2M
rclone copy /share/folder2/ remote:/folder2/current --backup-dir remote:/folder2/`date +%Y-%m-%d__%H-%M-%S`/ -v --log-file=/var/log/rclone.log --bwlimit=2M
wget --no-check-certificate https://hc-ping.com/<id>/$?
exit

```

and other folder (in total are 10 shared folders)  
my problem is exit code, how can i have only 1 exit code to send/check with [https://healthchecks.io](https://healthchecks.io) ?

thank you in advance

---

<div class="post-metadata">

**Author:** ![asdffdsa](https://forum.rclone.org/letter_avatar_proxy/v4/letter/a/848f3c/32.png) [@asdffdsa](https://forum.rclone.org/u/asdffdsa)\
**Post date:** [March 12, 2023, 1:37pm UTC](https://forum.rclone.org/t/help-with-simple-script-copy-multiple-folder-and-exit-code/36716/2 "2023-03-12T13:37:57Z")

</div>

try something like

1. create a text file with the name of the folders, `list.txt`

```auto
/folder1/**
/folder2/**

```

1. have rclone use the list, only those two folders will be copied.

```auto
rclone copy /share remote:current --include-from=list.txt --backup-dir=remote:folders/`date +%Y-%m-%d__%H-%M-%S`/ -v --log-file=/var/log/rclone.log --bwlimit=2M

```

---

<div class="post-metadata">

**Author:** ![ale82x](https://forum.rclone.org/user_avatar/forum.rclone.org/ale82x/32/1610_2.png) [@ale82x](https://forum.rclone.org/u/ale82x)\
**Post date:** [March 12, 2023, 7:38pm UTC](https://forum.rclone.org/t/help-with-simple-script-copy-multiple-folder-and-exit-code/36716/3 "2023-03-12T19:38:49Z")

</div>

thank you.  
i try to use with list.txt

but when i run my script i have exit code 0 (so seems ok)  
but in log file there is

2023/03/12 20:35:00 INFO : Starting bandwidth limiter at 2Mi Byte/s  
2023/03/12 20:35:03 INFO : There was nothing to transfer  
2023/03/12 20:35:03 INFO :  
Transferred: 0 B / 0 B, -, 0 B/s, ETA -  
Elapsed time: 3.0s

but name of different folder is correct...

thank you

---

<div class="post-metadata">

**Author:** ![asdffdsa](https://forum.rclone.org/letter_avatar_proxy/v4/letter/a/848f3c/32.png) [@asdffdsa](https://forum.rclone.org/u/asdffdsa)\
**Post date:** [March 12, 2023, 7:42pm UTC](https://forum.rclone.org/t/help-with-simple-script-copy-multiple-folder-and-exit-code/36716/4 "2023-03-12T19:42:04Z")

</div>

ok, run the command with `-vv`

---

<div class="post-metadata">

**Author:** ![ale82x](https://forum.rclone.org/user_avatar/forum.rclone.org/ale82x/32/1610_2.png) [@ale82x](https://forum.rclone.org/u/ale82x)\
**Post date:** [March 12, 2023, 9:26pm UTC](https://forum.rclone.org/t/help-with-simple-script-copy-multiple-folder-and-exit-code/36716/5 "2023-03-12T21:26:18Z")

</div>

sorry but I hadn't thought of that

here log with -vv

2023/03/12 22:19:22 INFO : Starting bandwidth limiter at 2Mi Byte/s  
2023/03/12 22:19:22 DEBUG : rclone: Version "v1.61.1" starting with parameters ["/share/homes/admin/rclone" "copy" "/share" "remote:/bck-rclone2/" "--include-from=/share/homes/admin/list.txt" "--backup-dir" "remote:/bck-rclone2/folders/2023-03-12\_\_22-19-22/" "-vv" "--log-file=/share/homes/admin/script\_bck\_rclone2.log" "--bwlimit=2M"]  
2023/03/12 22:19:22 DEBUG : Creating backend with remote "/share"  
2023/03/12 22:19:22 DEBUG : Using config file from "/root/.config/rclone/rclone.conf"  
2023/03/12 22:19:22 DEBUG : Creating backend with remote "remote:/bck-rclone2/"  
2023/03/12 22:19:27 DEBUG : fs cache: renaming cache item "remote:/bck-rclone2/" to be canonical "remote:bck-rclone2"  
2023/03/12 22:19:27 DEBUG : Creating backend with remote "remote:/bck-rclone2/folders/2023-03-12\_\_22-19-22/"  
2023/03/12 22:19:31 DEBUG : fs cache: renaming cache item "remote:/bck-rclone2/folders/2023-03-12\_\_22-19-22/" to be canonical "remote:bck-rclone2/folders/2023-03-12\_\_22-19-22"  
2023/03/12 22:19:31 DEBUG : .proftpd.fifo: Excluded  
2023/03/12 22:19:31 DEBUG : CACHEDEV1\_DATA: Excluded  
2023/03/12 22:19:31 DEBUG : external: Excluded  
2023/03/12 22:19:31 DEBUG : HDZ\_DATA: Excluded  
2023/03/12 22:19:31 DEBUG : HDY\_DATA: Excluded  
2023/03/12 22:19:31 DEBUG : HDX\_DATA: Excluded  
2023/03/12 22:19:31 DEBUG : HDW\_DATA: Excluded  
2023/03/12 22:19:31 DEBUG : HDV\_DATA: Excluded  
2023/03/12 22:19:31 DEBUG : HDU\_DATA: Excluded  
2023/03/12 22:19:31 DEBUG : HDT\_DATA: Excluded  
2023/03/12 22:19:31 DEBUG : HDS\_DATA: Excluded  
2023/03/12 22:19:31 DEBUG : HDR\_DATA: Excluded  
2023/03/12 22:19:31 DEBUG : HDQ\_DATA: Excluded  
2023/03/12 22:19:31 DEBUG : HDP\_DATA: Excluded  
2023/03/12 22:19:31 DEBUG : HDO\_DATA: Excluded  
2023/03/12 22:19:31 DEBUG : HDN\_DATA: Excluded  
2023/03/12 22:19:31 DEBUG : HDM\_DATA: Excluded  
2023/03/12 22:19:31 DEBUG : HDL\_DATA: Excluded  
2023/03/12 22:19:31 DEBUG : HDK\_DATA: Excluded  
2023/03/12 22:19:31 DEBUG : HDJ\_DATA: Excluded  
2023/03/12 22:19:31 DEBUG : HDI\_DATA: Excluded  
2023/03/12 22:19:31 DEBUG : HDH\_DATA: Excluded  
2023/03/12 22:19:31 DEBUG : HDG\_DATA: Excluded  
2023/03/12 22:19:31 DEBUG : HDF\_DATA: Excluded  
2023/03/12 22:19:31 DEBUG : HDE\_DATA: Excluded  
2023/03/12 22:19:31 DEBUG : HDD\_DATA: Excluded  
2023/03/12 22:19:31 DEBUG : HDC\_DATA: Excluded  
2023/03/12 22:19:31 DEBUG : HDB\_DATA: Excluded  
2023/03/12 22:19:31 DEBUG : HDA\_DATA: Excluded  
2023/03/12 22:19:32 DEBUG : Google drive root 'bck-rclone2': Waiting for checks to finish  
2023/03/12 22:19:32 DEBUG : Google drive root 'bck-rclone2': Waiting for transfers to finish  
2023/03/12 22:19:32 INFO : There was nothing to transfer  
2023/03/12 22:19:32 INFO :  
Transferred: 0 B / 0 B, -, 0 B/s, ETA -  
Elapsed time: 9.9s

2023/03/12 22:19:32 DEBUG : 12 go routines active

of course that excluded is name of folder that i DO NOT WANT backup, so seems ok but "was nothing to transfer"

thank you again

---

<div class="post-metadata">

**Author:** ![asdffdsa](https://forum.rclone.org/letter_avatar_proxy/v4/letter/a/848f3c/32.png) [@asdffdsa](https://forum.rclone.org/u/asdffdsa)\
**Post date:** [March 12, 2023, 9:32pm UTC](https://forum.rclone.org/t/help-with-simple-script-copy-multiple-folder-and-exit-code/36716/6 "2023-03-12T21:32:14Z")

</div>

not sure,

tho, maybe  
`remote:/bck-rclone2`  
should be  
`remote:/bck-rclone2/current`

---

<div class="post-metadata">

**Author:** ![ale82x](https://forum.rclone.org/user_avatar/forum.rclone.org/ale82x/32/1610_2.png) [@ale82x](https://forum.rclone.org/u/ale82x)\
**Post date:** [March 13, 2023, 6:06am UTC](https://forum.rclone.org/t/help-with-simple-script-copy-multiple-folder-and-exit-code/36716/7 "2023-03-13T06:06:44Z")

</div>

same...

```auto
2023/03/13 06:57:49 DEBUG : rclone: Version "v1.61.1" starting with parameters ["/share/homes/admin/rclone" "copy" "/share" "remote:/bck-rclone2/current/" "--include-from=/share/homes/admin/list.txt" "--backup-dir" "remote:/bck-rclone2/folders/2023-03-13__06-57-48/" "-vv" "--log-file=/share/homes/admin/script_bck_rclone2.log" "--bwlimit=2M"]
2023/03/13 06:57:49 DEBUG : Creating backend with remote "/share"
2023/03/13 06:57:49 DEBUG : Using config file from "/root/.config/rclone/rclone.conf"
2023/03/13 06:57:49 DEBUG : Creating backend with remote "remote:/bck-rclone2/current/"
2023/03/13 06:57:50 DEBUG : fs cache: renaming cache item "remote:/bck-rclone2/current/" to be canonical "remote:bck-rclone2/current"
2023/03/13 06:57:50 DEBUG : Creating backend with remote "remote:/bck-rclone2/folders/2023-03-13__06-57-48/"
2023/03/13 06:57:51 DEBUG : fs cache: renaming cache item "remote:/bck-rclone2/folders/2023-03-13 __06-57-48/" to be canonical "remote:bck-rclone2/folders/2023-03-13__ 06-57-48"
2023/03/13 06:57:51 DEBUG : .proftpd.fifo: Excluded
2023/03/13 06:57:51 DEBUG : CACHEDEV1_DATA: Excluded
2023/03/13 06:57:51 DEBUG : external: Excluded
2023/03/13 06:57:51 DEBUG : HDZ_DATA: Excluded
2023/03/13 06:57:51 DEBUG : HDY_DATA: Excluded
2023/03/13 06:57:51 DEBUG : HDX_DATA: Excluded
2023/03/13 06:57:51 DEBUG : HDW_DATA: Excluded
2023/03/13 06:57:51 DEBUG : HDV_DATA: Excluded
2023/03/13 06:57:51 DEBUG : HDU_DATA: Excluded
2023/03/13 06:57:51 DEBUG : HDT_DATA: Excluded
2023/03/13 06:57:51 DEBUG : HDS_DATA: Excluded
2023/03/13 06:57:51 DEBUG : HDR_DATA: Excluded
2023/03/13 06:57:51 DEBUG : HDQ_DATA: Excluded
2023/03/13 06:57:51 DEBUG : HDP_DATA: Excluded
2023/03/13 06:57:51 DEBUG : HDO_DATA: Excluded
2023/03/13 06:57:51 DEBUG : HDN_DATA: Excluded
2023/03/13 06:57:51 DEBUG : HDM_DATA: Excluded
2023/03/13 06:57:51 DEBUG : HDL_DATA: Excluded
2023/03/13 06:57:51 DEBUG : HDK_DATA: Excluded
2023/03/13 06:57:51 DEBUG : HDJ_DATA: Excluded
2023/03/13 06:57:51 DEBUG : HDI_DATA: Excluded
2023/03/13 06:57:51 DEBUG : HDH_DATA: Excluded
2023/03/13 06:57:51 DEBUG : HDG_DATA: Excluded
2023/03/13 06:57:51 DEBUG : HDF_DATA: Excluded
2023/03/13 06:57:51 DEBUG : HDE_DATA: Excluded
2023/03/13 06:57:51 DEBUG : HDD_DATA: Excluded
2023/03/13 06:57:51 DEBUG : HDC_DATA: Excluded
2023/03/13 06:57:51 DEBUG : HDB_DATA: Excluded
2023/03/13 06:57:51 DEBUG : HDA_DATA: Excluded
2023/03/13 06:57:51 DEBUG : Google drive root 'bck-rclone2/current': Waiting for checks to finish
2023/03/13 06:57:51 DEBUG : Google drive root 'bck-rclone2/current': Waiting for transfers to finish
2023/03/13 06:57:51 INFO : There was nothing to transfer
2023/03/13 06:57:51 INFO :
Transferred: 0 B / 0 B, -, 0 B/s, ETA -
Elapsed time: 2.7s

```

if i use this script

```auto
#!/bin/bash
REMOTE=remote:/bck-rclone
DEST_DATE=`date +%Y-%m-%d__%H-%M-%S`/
LOG=/share/homes/admin/script_bck_rclone.log
BWLIMIT=2M
FOLDER1=folder1
/share/homes/admin/rclone copy /share/$FOLDER1/ $REMOTE/$FOLDER1/current/ --backup-dir $REMOTE/$FOLDER1/$DEST_DATE -v --log-file=$LOG --bwlimit=$BWLIMIT
if [[$? -ne 0]]; then
FOLDER2=folder2
/share/homes/admin/rclone copy /share/$FOLDER2/ $REMOTE/$FOLDER2/current/ --backup-dir $REMOTE/$FOLDER2/$DEST_DATE -v --log-file=$LOG --bwlimit=$BWLIMIT
if [[$? -ne 0]]; then
wget --no-check-certificate https://hc-ping.com/<id>/$? -T 10 -t 5 -O /dev/null
fi
fi
exit

```

so if i have exit code 0 on first "copy" switch to second (of course indeed i use ten if)  
and when the last finish with exit code 0 send to healthcheck  
is not clean but seems my limit ...

thank you

---

<div class="post-metadata">

**Author:** ![system](https://forum.rclone.org/uploads/default/original/2X/3/39ad3235f6ffec76ccd0c81616bd55697b4c300d.png) [@system](https://forum.rclone.org/u/system)\
**Post date:** [April 12, 2023, 6:06am UTC](https://forum.rclone.org/t/help-with-simple-script-copy-multiple-folder-and-exit-code/36716/8 "2023-04-12T06:06:46Z")

</div>

Closed on April 12, 2023, 6:06am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
