Install netatalk and avahi-daemon with

sudo apt-get install netatalk avahi-daemon

then create a backup directory, e.g.,

/disk/timemachine

and make sure it is assigned to an owner (e.g., macuser) for which you know the password. Now modify

/etc/netatalk/afpd.conf

adding at the end this line

- -tcp -noddp -uamlist uams_randnum.so,uams_dhx.so,uams_dhx2.so -nosavepassword

and modify

/etc/netatalk/AppleVolumes.default

adding at the end (change <username> with whatever you picked before)

/disk/timemachine TimeMachine allow:<username> cnidscheme:dbd options:usedots,upriv,tm

Now create the file

/etc/avahi/services/afpd.service

and write in it

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
    <name replace-wildcards="yes">%h</name>
    <service>
        <type>_afpovertcp._tcp</type>
        <port>548</port>
    </service>
    <service>
        <type>_device-info._tcp</type>
        <port>0</port>
        <txt-record>model=MacPro</txt-record>
    </service>
</service-group>

You are done, just restart the services

restart netatalk
restart avahi-daemon
Source: langit.wordpress.com