Determine available disk space Print

  • diskspace, Space, Available, availablespace
  • 0

To determine in a script how much available disk space you have, use the program "sftp" in Linux-based systems:

echo "df"     | sftp <sr-your_storage_number>
echo "df -h"  | sftp <sr-your_storage_number>
echo "df -hi" | sftp <sr-your_storage_number>

Under certain circumstances, lftp can return wrong values; therefore it is better to use the variant with sftp. Below is the variant with lftp:

# apt-get install lftp
# echo du -hs .  \
| lftp -u <username>,<password> BACKUPSERVER

You can also embed the command in Tartarus using a hook. To do this, insert the following lines into the Tartarus configuration:

echo "du" | /usr/bin/lftp -u "$STORAGE_FTP_USER,$STORAGE_FTP_PASSWORD" "$STORAGE_FTP_SERVER" | awk -v LIMIT=100 '$2=="." {print ((LIMIT*1024*1024)-$1)/1024 " MiB backup space remaining"}'


Got a question? Connect with us and Create a Ticket.

Was this answer helpful?

« Back