Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syntax error in expression in free space check #72

Closed
RandomNamer opened this issue Jun 24, 2024 · 5 comments
Closed

syntax error in expression in free space check #72

RandomNamer opened this issue Jun 24, 2024 · 5 comments

Comments

@RandomNamer
Copy link

Hi, I been trying to use the script, release 3.0.52 to first backup then migrate container manager to another volume. It did succeed in backing up other packages however failed on container manager. Here's some log with trace on:

You selected Container Manager in /volume1

Destination volume is /volume1

Ready to Backup Container Manager to /volume1/homes/zzy/Backups/SynoAppMover? [y/n]
y

prepare_backup_restore called from main
stop_packages called from main
package_is_running called from stop_packages
process_packages called from main
check_space called from process_packages
folder_size called from check_space
vol_free_space called from check_space
./syno_app_mover.sh: line 786: [[: 6609783028
6609783028: syntax error in expression (error token is "6609783028")
WARNING Not enough space to backup /volume1/@docker to /volume1
Free: 6609783028
6609783028  Needed: 128881640 in B (plus 50 GB buffer)

ding called from process_packages
ERROR Not enough space on /volume1 to backup @docker!

So the free space check is correct, it is 6609783028, which is ~6.15TiB and the @docker folder size is 128881640, which is ~123GB. It seems some error happened here at ln 786 and the script thought there is no free space.

@007revad
Copy link
Owner

Did it actually show

Free: 6609783028
6609783028  Needed: 128881640 in B (plus 50 GB buffer)

instead of

Free: 6609783028  Needed: 128881640 in B (plus 50 GB buffer)

@RandomNamer
Copy link
Author

Did it actually show

Free: 6609783028
6609783028  Needed: 128881640 in B (plus 50 GB buffer)

instead of

Free: 6609783028  Needed: 128881640 in B (plus 50 GB buffer)

Yes.
image

For your context: I tweaked the script a little. At first it failed at ln. 789, I thought it was something wrong with the GiB calculation, then I just changed that line to echo -en "Free: $free Needed: $need in B". Then it failed at 786 and outputs as mentioned before.

@007revad
Copy link
Owner

The script used to use df --output=avail "$1" | grep -A1 Avail | grep -v Avail (where $1 is /volume1 etc).

but a week ago, in v3.0.51, I changed it to df | grep "$1" | awk '{print $4}' to also work for USB drives.

I suspect if you run the following command you'll get 2 results

df | grep /volume1

My /volume1 has a symlink that points to a remote mounted CIFS share so I'm also seeing 2 results:

# df | grep /volume1
/dev/mapper/cachedev_2 44971327488 15028185224 29943142264  34% /volume1
\\192.168.20.190\video 35142887424 19176553044 15966334380  55% /volume1/nimbustor/video

# df | grep /volume1 | awk '{print $4}'
29943142264
15966334380

Assuming you are seeing the same thing the fix will be easy:

# df | grep /volume1$ | awk '{print $4}'
29943142264

So line 770 would be changed to:

free=$(df | grep "$1"$ | awk '{print $4}')

007revad added a commit that referenced this issue Jun 24, 2024
v3.0.53
- Bug fix checking target volume free space when there's a symlink on the volume. Issue #72
  - e.g. A symlink pointing to folder on same volume, another volume or another device.
@007revad 007revad mentioned this issue Jun 24, 2024
@RandomNamer
Copy link
Author

The script used to use df --output=avail "$1" | grep -A1 Avail | grep -v Avail (where $1 is /volume1 etc).

but a week ago, in v3.0.51, I changed it to df | grep "$1" | awk '{print $4}' to also work for USB drives.

I suspect if you run the following command you'll get 2 results

df | grep /volume1

My /volume1 has a symlink that points to a remote mounted CIFS share so I'm also seeing 2 results:

# df | grep /volume1
/dev/mapper/cachedev_2 44971327488 15028185224 29943142264  34% /volume1
\\192.168.20.190\video 35142887424 19176553044 15966334380  55% /volume1/nimbustor/video

# df | grep /volume1 | awk '{print $4}'
29943142264
15966334380

Assuming you are seeing the same thing the fix will be easy:

# df | grep /volume1$ | awk '{print $4}'
29943142264

So line 770 would be changed to:

free=$(df | grep "$1"$ | awk '{print $4}')

Thank you Dave, I believe that's the exact cause. I have enabled "visible snapshots" in some shared folders, turns out under the hood the system just created links pointing these snapshot folders, so there are multiple lines for free space.

(synogear) root@DS1522p:/volume1/homes/zzy# df | grep /volume1
/dev/mapper/cachedev_2 18739479184 12267040596 6472438588  66% /volume1
/dev/mapper/cachedev_2 18739479184 12267040596 6472438588  66% /volume1/medialibrary/#snapshot
(synogear) root@DS1522p:/volume1/homes/zzy# df | grep /volume1 | awk '{print $4}'
6472438612
6472438612
(synogear) root@DS1522p:/volume1/homes/zzy# df | grep /volume2
/dev/mapper/cachedev_1  1811939328   247280236 1564659092  14% /volume2
/dev/mapper/cachedev_1  1811939328   247280236 1564659092  14% /volume2/docker/#snapshot

@007revad
Copy link
Owner

Fixed in v3.0.53
https://github.com/007revad/Synology_app_mover/releases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants