How to fix rsync: getcwd(): No such file or directory (2)

Hi,
I am running the following for javaapp to replicate files between two servers behind AWS ELB:

# /usr/bin/rsync --dry-run -v -az -H --delete --numeric-ids --exclude=cache/staic --exclude=.well-known/ /var/snap/lxd/common/mntns/var/snap/lxd/common/lxd/storage-pools/zfs/containers/prod/rootfs/app/ root@ec-2.www-2:/var/snap/lxd/common/mntns/var/snap/lxd/common/lxd/storage-pools/zfs/containers/prod/rootfs/app

But keep getting:

rsync: getcwd(): No such file or directory (2)
rsync error: errors selecting input/output files, dirs (code 3) at util.c(1221) [Receiver=3.1.3]

What does it means? How do I fix it? Both are Ubuntu servers.

You must be in source directory when ran the rsync and either that dir was part of container or some other process. In other cases $PWD wasn’t updated by shell. What you need to do is get out of the following folder:

You can do that by typing any one of the following command:

cd
cd /tmp
echo "$PWD"

Then run the command again:

# /usr/bin/rsync --dry-run -v -az -H --delete --numeric-ids \
--exclude=cache/staic --exclude=.well-known/ \
/var/snap/lxd/common/mntns/var/snap/lxd/common/lxd/storage-pools/zfs/containers/prod/rootfs/app/ \
root@ec-2.www-2:/var/snap/lxd/common/mntns/var/snap/lxd/common/lxd/storage-pools/zfs/containers/prod/rootfs/app

It should work now.