hard links and check iNode number
>>> import errno
>>> os.link(fileA, fileB)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 17] File exists
>>> try:
... os.link(fileA, fileB)
... except OSError, err:
... print err.errno
...
17
>>> print errno.EACCES
13
>>> print errno.EEXIST
17
https://docs.python.org/2/library/errno.html
>>> import os
>>> fileA = '/backup/dbC/lock_files/backup_running'
>>> fileB = '/backup/dbC/lock_files/si_bkp_ongoing'
>>> os.lstat(fileA).st_ino
400071
>>> os.lstat(fileB).st_ino
412219
>>> os.remove(fileB)
>>> os.link(fileA, fileB)
>>> os.lstat(fileA).st_ino
400071
>>> os.lstat(fileB).st_ino
400071